Skip to content

Commit

Permalink
Solved all major issues, ready for beta
Browse files Browse the repository at this point in the history
  • Loading branch information
hunvreus committed Jan 6, 2024
1 parent 7144369 commit 2c734d8
Show file tree
Hide file tree
Showing 51 changed files with 3,671 additions and 1,635 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ coverage
*.local
.*

wrangler.toml

/cypress/videos/
/cypress/screenshots/

Expand Down
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIT License

Copyright (c) 2023 Ronan Berder

Unless otherwise specified in a LICENSE file within an individual package directory,
this license applies to all files in this repository outside of those package directories.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 5 additions & 5 deletions functions/auth/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export async function onRequest(context) {
'Accept': 'application/json',
},
body: JSON.stringify({
client_id: env.CLIENT_ID,
client_secret: env.CLIENT_SECRET,
client_id: env.GITHUB_CLIENT_ID,
client_secret: env.GITHUB_CLIENT_SECRET,
code: url.searchParams.get('code'),
redirect_uri: `${new URL(request.url).origin}/auth/callback`,
}),
Expand All @@ -22,10 +22,10 @@ export async function onRequest(context) {
throw new Error(`Error fetching access token: ${response.statusText}. GitHub says: ${errorText}`);
}

const data = await response.json();
const responseData = await response.json();

if (data.access_token) {
return Response.redirect(`${env.CLIENT_URL}/?access_token=${data.access_token}`, 302);
if (responseData.access_token) {
return Response.redirect(`${env.CLIENT_URL}/?access_token=${responseData.access_token}`, 302);
} else {
throw new Error('Access token not found');
}
Expand Down
4 changes: 2 additions & 2 deletions functions/auth/login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export async function onRequest(context) {
const { env } = context;
const REDIRECT_URI = `${new URL(context.request.url).origin}/auth/callback`;
const redirect_uri = `${new URL(context.request.url).origin}/auth/callback`;

return Response.redirect(`https://github.com/login/oauth/authorize?client_id=${env.CLIENT_ID}&redirect_uri=${encodeURIComponent(REDIRECT_URI)}&scope=repo`, 302);
return Response.redirect(`https://github.com/login/oauth/authorize?client_id=${env.GITHUB_CLIENT_ID}&redirect_uri=${encodeURIComponent(redirect_uri)}&scope=repo`, 302);
}
4 changes: 2 additions & 2 deletions functions/auth/revoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export async function onRequest(context) {
return new Response('Token parameter is required', { status: 400 });
}

const response = await fetch(`https://api.github.com/applications/${env.CLIENT_ID}/grant`, {
const response = await fetch(`https://api.github.com/applications/${env.GITHUB_CLIENT_ID}/grant`, {
method: 'DELETE',
headers: {
'Authorization': `Basic ${btoa(`${env.CLIENT_ID}:${env.CLIENT_SECRET}`)}`,
'Authorization': `Basic ${btoa(`${env.GITHUB_CLIENT_ID}:${env.GITHUB_CLIENT_SECRET}`)}`,
'Content-Type': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'Pages CMS'
Expand Down
Loading

0 comments on commit 2c734d8

Please sign in to comment.