File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default function Counter() {
66 return (
77 < button
88 class = "w-[200px] rounded-full bg-gray-100 border-2 border-gray-300 focus:border-gray-400 active:border-gray-400 px-[2rem] py-[1rem]"
9- onClick = { ( ) => setCount ( count ( ) + 1 ) }
9+ onclick = { ( ) => setCount ( count ( ) + 1 ) }
1010 >
1111 Clicks: { count ( ) }
1212 </ button >
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export const querySession = query(async (path: string) => {
1616 const { data } = await getSession ( ) ;
1717 if ( path === "/login" && data . id ) return redirect ( "/" ) ;
1818 if ( data . id ) return data ;
19- if ( isProtectedRoute ( path ) ) throw redirect ( " /login" ) ;
19+ if ( isProtectedRoute ( path ) ) throw redirect ( ` /login?redirect= ${ path } ` ) ;
2020 return null ;
2121} , "session" ) ;
2222
Original file line number Diff line number Diff line change @@ -12,16 +12,17 @@ export const getSession = () =>
1212 password : process . env . SESSION_SECRET !
1313 } ) ;
1414
15- export const createSession = async ( { id, email } : Session ) => {
15+ export const createSession = async ( user : Session , dest ?: string ) => {
16+ const validDest = dest ?. [ 0 ] === "/" && dest [ 1 ] !== "/" ;
1617 const session = await getSession ( ) ;
17- await session . update ( { id , email } ) ;
18- return redirect ( "/" ) ;
18+ await session . update ( user ) ;
19+ return redirect ( validDest ? dest : "/" ) ;
1920} ;
2021
21- export const oauthSignIn = async ( email : string ) => {
22+ export const oauthSignIn = async ( email : string , dest ?: string ) => {
2223 let user = await findUser ( { email } ) ;
2324 if ( ! user ) user = await createUser ( { email } ) ;
24- return createSession ( user ) ;
25+ return createSession ( user , dest ) ;
2526} ;
2627
2728export const passwordSignIn = async ( email : string , password : string ) => {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const config: Configuration = {
77 id : process . env . DISCORD_ID ! ,
88 secret : process . env . DISCORD_SECRET !
99 } ,
10- handler : async ( { email } ) => oauthSignIn ( email )
10+ handler : async ( { email } , redirect ) => oauthSignIn ( email , redirect )
1111} ;
1212
1313export const GET = OAuth ( config ) ;
You can’t perform that action at this time.
0 commit comments