When signing out, check if user is anonymous

This commit is contained in:
Korbs 2024-07-17 19:04:49 -04:00
parent 11856a0f04
commit 9628d5e48e

View file

@ -3,8 +3,13 @@ import { supabase } from "@library/supabase"
import type { Provider } from "@supabase/supabase-js" import type { Provider } from "@supabase/supabase-js"
export const GET: APIRoute = async ({ cookies, redirect }) => { export const GET: APIRoute = async ({ cookies, redirect }) => {
cookies.delete("sb-access-token", { path: "/" })
cookies.delete("sb-refresh-token", { path: "/" }) if(cookies.get('anonymous-session')) {
const { error } = await supabase.auth.signOut() return redirect('/account/anon/end')
return redirect("/signin") } else {
cookies.delete("sb-access-token", { path: "/" })
cookies.delete("sb-refresh-token", { path: "/" })
const { error } = await supabase.auth.signOut()
}
return redirect("/")
} }