From 9628d5e48e69b3a9945d2c794ebca01a564f0dad Mon Sep 17 00:00:00 2001 From: Korbs Date: Wed, 17 Jul 2024 19:04:49 -0400 Subject: [PATCH] When signing out, check if user is anonymous --- src/pages/api/auth/signout.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/api/auth/signout.ts b/src/pages/api/auth/signout.ts index 5ba4355..ea87725 100644 --- a/src/pages/api/auth/signout.ts +++ b/src/pages/api/auth/signout.ts @@ -3,8 +3,13 @@ import { supabase } from "@library/supabase" import type { Provider } from "@supabase/supabase-js" export const GET: APIRoute = async ({ cookies, redirect }) => { - cookies.delete("sb-access-token", { path: "/" }) - cookies.delete("sb-refresh-token", { path: "/" }) - const { error } = await supabase.auth.signOut() - return redirect("/signin") + + if(cookies.get('anonymous-session')) { + return redirect('/account/anon/end') + } else { + cookies.delete("sb-access-token", { path: "/" }) + cookies.delete("sb-refresh-token", { path: "/" }) + const { error } = await supabase.auth.signOut() + } + return redirect("/") } \ No newline at end of file