mirror of https://github.com/buster-so/buster.git
added error handling
This commit is contained in:
parent
70b3421d34
commit
a1fa893bff
|
@ -7,6 +7,7 @@ export async function GET(request: Request) {
|
||||||
const code = searchParams.get('code_challenge') || searchParams.get('code'); //we were not seeing code, just code_challenge?
|
const code = searchParams.get('code_challenge') || searchParams.get('code'); //we were not seeing code, just code_challenge?
|
||||||
// if "next" is in param, use it as the redirect URL
|
// if "next" is in param, use it as the redirect URL
|
||||||
const next = searchParams.get('next') ?? '/';
|
const next = searchParams.get('next') ?? '/';
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
||||||
|
@ -23,6 +24,8 @@ export async function GET(request: Request) {
|
||||||
return NextResponse.redirect(`${origin}/app`);
|
return NextResponse.redirect(`${origin}/app`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.error('ERROR EXCHANGING CODE FOR SESSION', { error });
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the user to an error page with instructions
|
// return the user to an error page with instructions
|
||||||
|
|
|
@ -20,9 +20,14 @@ export async function GET(request: NextRequest) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
// redirect user to specified redirect URL or root of app
|
// redirect user to specified redirect URL or root of app
|
||||||
redirect(next);
|
redirect(next);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.error('NO TOKEN HASH OR TYPE', { token_hash, type });
|
||||||
|
|
||||||
// redirect the user to an error page with some instructions
|
// redirect the user to an error page with some instructions
|
||||||
redirect('/auth/auth-code-error');
|
redirect('/auth/auth-code-error');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue