From 809f2751eadd72dff401421900f00cf3ea6af111 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 18 Apr 2025 09:37:02 -0600 Subject: [PATCH] supabase docs are wrong. dead wrong. --- web/src/app/auth/confirm/route.ts | 2 +- .../features/auth/SignOutHandler.tsx | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/web/src/app/auth/confirm/route.ts b/web/src/app/auth/confirm/route.ts index 2b87f92a8..ce0f84df2 100644 --- a/web/src/app/auth/confirm/route.ts +++ b/web/src/app/auth/confirm/route.ts @@ -6,7 +6,7 @@ import { redirect } from 'next/navigation'; export async function GET(request: NextRequest) { const { searchParams } = new URL(request.url); - const token_hash = searchParams.get('token_hash'); + const token_hash = searchParams.get('token_hash') || searchParams.get('code'); //THE SUPABASE DOCS ARE WRONG! const type = searchParams.get('type') as EmailOtpType | null; const next = searchParams.get('next') ?? '/'; diff --git a/web/src/components/features/auth/SignOutHandler.tsx b/web/src/components/features/auth/SignOutHandler.tsx index ec9d93a00..9765c360b 100644 --- a/web/src/components/features/auth/SignOutHandler.tsx +++ b/web/src/components/features/auth/SignOutHandler.tsx @@ -3,15 +3,28 @@ import { useCallback } from 'react'; import { signOut } from '@/lib/supabase/signOut'; import { clearAllBrowserStorage } from '@/lib/browser/storage'; +import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; +import { BusterRoutes } from '@/routes/busterRoutes'; +import { useBusterNotifications } from '@/context/BusterNotifications'; export const useSignOut = () => { + const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage); + const { openErrorMessage } = useBusterNotifications(); const handleSignOut = useCallback(async () => { - // First clear all client-side storage - clearAllBrowserStorage(); + try { + // Then perform server-side sign out + await signOut(); - // Then perform server-side sign out - await signOut(); - }, []); + // First clear all client-side storage + clearAllBrowserStorage(); + + await onChangePage({ + route: BusterRoutes.AUTH_LOGIN + }); + } catch (error) { + openErrorMessage('Error signing out'); + } + }, [onChangePage, openErrorMessage]); return handleSignOut; };