Create professional demos and 3D mockups in seconds, directly in your browser
feat: update sign-out functionality to include local scope and handle session errors
CristianOlivera1146ef5cbacd5
diff --git a/app/contexts/useAuth.tsx b/app/contexts/useAuth.tsxindex 41d25b3..ca05cd9 100644--- a/app/contexts/useAuth.tsx+++ b/app/contexts/useAuth.tsx@@ -121,7 +121,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {setProfile(null);setSession(null);- const { error } = await supabase.auth.signOut();+ const { error } = await supabase.auth.signOut({ scope: "local" });if (error) {console.error("Error signing out:", error);}diff --git a/utils/supabase/middleware.ts b/utils/supabase/middleware.tsindex 0e65597..fd9871a 100644--- a/utils/supabase/middleware.ts+++ b/utils/supabase/middleware.ts@@ -78,8 +78,26 @@ export async function updateSession(const {data: { user },+ error,} = await supabase.auth.getUser();+ if (error?.code === "refresh_token_not_found" || error?.code === "session_not_found") {+ await supabase.auth.signOut({ scope: "local" });+ const authCookieNames = request.cookies+ .getAll()+ .filter((c) => c.name.includes("-auth-token"))+ .map((c) => c.name);++ const applyAuthCookies = (target: NextResponse): boolean => {+ authCookieNames.forEach((name) => {+ target.cookies.delete(name);+ });+ return authCookieNames.length > 0;+ };++ return { user: null, applyAuthCookies };+ }+const applyAuthCookies = (target: NextResponse): boolean => {if (cookiesToApply.length === 0) return false;