File tree Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 250250 toast .success (" Logged out" , {
251251 description: " You have been logged out. Refreshing in 3 seconds..." ,
252252 duration: 3000 ,
253- onAutoClose: location .reload
253+ onAutoClose : () => location .reload ()
254254 });
255255 }}
256256 class =" cursor-pointer text-red-500"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { redirect } from "@sveltejs/kit";
22import { generateState } from "arctic" ;
33import { github } from "$lib/server/auth" ;
44
5- export async function GET ( { cookies } ) {
5+ export async function load ( { cookies } ) {
66 const state = generateState ( ) ;
77 const url = await github . createAuthorizationURL ( state ) ;
88
Original file line number Diff line number Diff line change 1+ import { error , redirect } from "@sveltejs/kit" ;
12import { github } from "$lib/server/auth" ;
23import { tokenKey } from "$lib/types" ;
34
4- export async function GET ( { cookies, url } ) {
5+ export async function load ( { cookies, url } ) {
56 const code = url . searchParams . get ( "code" ) ;
67 const state = url . searchParams . get ( "state" ) ;
78 const storedState = cookies . get ( "github_oauth_state" ) ?? null ;
89
910 if ( ! code || ! state || ! storedState || state !== storedState ) {
10- return new Response ( null , {
11- status : 400
12- } ) ;
11+ error ( 400 ) ;
1312 }
1413 cookies . delete ( "github_oauth_state" , {
1514 path : "/"
1615 } ) ;
1716
1817 const tokens = await github . validateAuthorizationCode ( code ) ;
1918
20- return new Response ( null , {
21- status : 302 ,
22- headers : {
23- Location : `/?${ tokenKey } =${ tokens . accessToken } `
24- }
25- } ) ;
19+ return redirect ( 302 , `/?${ tokenKey } =${ tokens . accessToken } ` ) ;
2620}
You can’t perform that action at this time.
0 commit comments