update pay function
This commit is contained in:
35
boilerplate-chakra-pro-main/app/auth/callback/route.ts
Normal file
35
boilerplate-chakra-pro-main/app/auth/callback/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { getErrorRedirect, getStatusRedirect } from '@/utils/helpers';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
// The `/auth/callback` route is required for the server-side auth flow implemented
|
||||
// by the `@supabase/ssr` package. It exchanges an auth code for the user's session.
|
||||
const requestUrl = new URL(request.url);
|
||||
const code = requestUrl.searchParams.get('code');
|
||||
|
||||
if (code) {
|
||||
const supabase = createClient();
|
||||
|
||||
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
||||
|
||||
if (error) {
|
||||
return NextResponse.redirect(
|
||||
getErrorRedirect(
|
||||
`${requestUrl.origin}/dashboard/signin`,
|
||||
error.name,
|
||||
"Sorry, we weren't able to log you in. Please try again."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// URL to redirect to after sign in process completes
|
||||
return NextResponse.redirect(
|
||||
getStatusRedirect(
|
||||
`${requestUrl.origin}/dashboard/main`,
|
||||
'Success!',
|
||||
'You are now signed in.'
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user