supabase docs are wrong. dead wrong.

This commit is contained in:
Nate Kelley 2025-04-18 09:37:02 -06:00
parent fcaaddef5d
commit 809f2751ea
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 19 additions and 6 deletions

View File

@ -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') ?? '/';

View File

@ -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;
};