Added routing for callback after email confirmation, new packages
This commit is contained in:
1 parent
30edfab0a3
commit
92b4b1cfd5
2 files changed
+7521
No files matched your search
@@ -0,0 +1,22 @@
|
|||||||
|
import { createClient } from "@/utils/supabase/server";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
const { searchParams, origin } = new URL(request.url);
|
||||||
|
|
||||||
|
const code = searchParams.get("code");
|
||||||
|
// If the user clicked the email confirmation link, there may be a "next" param
|
||||||
|
const next = searchParams.get("next") ?? "/profile";
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
const supabase = await createClient();
|
||||||
|
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
return NextResponse.redirect(`${origin}${next}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no code or exchange failed, redirect to login with an error
|
||||||
|
return NextResponse.redirect(`${origin}/login?error=confirmation-failed`);
|
||||||
|
}
|
||||||
Generated
+7499
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user