Skip to content

Commit c467589

Browse files
committed
fix: auth
1 parent 18b1dc0 commit c467589

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

docs/src/pages/auth/authorize.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ export async function GET({url, redirect}) {
88

99
const myUrl = new URL(url);
1010
const params = new URLSearchParams(myUrl.search);
11-
const redirectUrl = params.get('redirect_uri');
11+
const redirect_uri = params.get('redirect_uri');
1212

1313
const { GITHUB_CLIENT_ID } = import.meta.env;
1414

15-
16-
const redirect_uri = 'http://localhost:4321/auth/authorized'
17-
const state = toHexString(redirectUrl);
15+
const state = toHexString(redirect_uri);
1816

1917
const oauthParams = new URLSearchParams({ client_id:GITHUB_CLIENT_ID , redirect_uri, state });
2018
return redirect(`${GITHUB_OAUTH_AUTHORIZE_URL}?${oauthParams}`, 302)

docs/src/pages/auth/authorized.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { fromHexString } from '../../utils/encrypt';
33
export const prerender = false;
44

55
const GITHUB_OAUTH_ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token';
6-
const TOKEN_VALIDITY_PERIOD = 1000 * 60 * 60 * 24 * 365; // 1 year;
76

87
export async function GET({ url, redirect, cookies}) {
98

@@ -17,8 +16,6 @@ export async function GET({ url, redirect, cookies}) {
1716

1817
const redirectUrl = new URL(fromHexString(state));
1918

20-
console.log('Authorized', GITHUB_CLIENT_ID);
21-
2219
if (error && error === 'access_denied') {
2320
redirect(redirectUrl.href, 302);
2421
return;
@@ -51,14 +48,11 @@ export async function GET({ url, redirect, cookies}) {
5148
status: 503
5249
}
5350
)
54-
return;
5551
}
5652

57-
// cookies.set('token', accessToken, { expires: new Date(Date.now() + TOKEN_VALIDITY_PERIOD), secure: true, httpOnly: true, path: '/' });
5853
cookies.set('refresh', refreshToken, { secure: true, httpOnly: true, path: '/' });
5954

6055
redirectUrl.searchParams.set('token', accessToken);
61-
// redirectUrl.searchParams.set('refresh', refreshToken);
6256

6357
return redirect(redirectUrl.href, 302);
6458
}

0 commit comments

Comments
 (0)