fix: update Dockerfile and remove .next from git
This commit is contained in:
27
app/auth/callback/route.ts
Normal file
27
app/auth/callback/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams, origin } = new URL(request.url)
|
||||
const code = searchParams.get('code')
|
||||
const next = searchParams.get('next') ?? '/app'
|
||||
const error = searchParams.get('error')
|
||||
const error_description = searchParams.get('error_description')
|
||||
|
||||
if (code) {
|
||||
const supabase = await createClient()
|
||||
const { error: supabaseError } = await supabase.auth.exchangeCodeForSession(code)
|
||||
if (!supabaseError) {
|
||||
await supabase.rpc('reactivate_profile')
|
||||
return NextResponse.redirect(`${origin}${next}`)
|
||||
}
|
||||
}
|
||||
|
||||
// If there's an error from Supabase or from the URL, forward it
|
||||
if (error) {
|
||||
return NextResponse.redirect(`${origin}/login?error=${globalThis.encodeURIComponent(error_description || error)}`)
|
||||
}
|
||||
|
||||
// return the user to an error page with instructions
|
||||
return NextResponse.redirect(`${origin}/login?code_error=true`)
|
||||
}
|
||||
11
app/auth/signout/route.ts
Normal file
11
app/auth/signout/route.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const requestUrl = new URL(request.url)
|
||||
const supabase = await createClient()
|
||||
|
||||
await supabase.auth.signOut()
|
||||
|
||||
return redirect(`${requestUrl.origin}/login`)
|
||||
}
|
||||
Reference in New Issue
Block a user