mirror of https://github.com/buster-so/buster.git
supabase docs are wrong. dead wrong.
This commit is contained in:
parent
fcaaddef5d
commit
809f2751ea
|
@ -6,7 +6,7 @@ import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
const { searchParams } = new URL(request.url);
|
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 type = searchParams.get('type') as EmailOtpType | null;
|
||||||
const next = searchParams.get('next') ?? '/';
|
const next = searchParams.get('next') ?? '/';
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,28 @@
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { signOut } from '@/lib/supabase/signOut';
|
import { signOut } from '@/lib/supabase/signOut';
|
||||||
import { clearAllBrowserStorage } from '@/lib/browser/storage';
|
import { clearAllBrowserStorage } from '@/lib/browser/storage';
|
||||||
|
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||||
|
import { BusterRoutes } from '@/routes/busterRoutes';
|
||||||
|
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||||
|
|
||||||
export const useSignOut = () => {
|
export const useSignOut = () => {
|
||||||
|
const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage);
|
||||||
|
const { openErrorMessage } = useBusterNotifications();
|
||||||
const handleSignOut = useCallback(async () => {
|
const handleSignOut = useCallback(async () => {
|
||||||
// First clear all client-side storage
|
try {
|
||||||
clearAllBrowserStorage();
|
// Then perform server-side sign out
|
||||||
|
await signOut();
|
||||||
|
|
||||||
// Then perform server-side sign out
|
// First clear all client-side storage
|
||||||
await signOut();
|
clearAllBrowserStorage();
|
||||||
}, []);
|
|
||||||
|
await onChangePage({
|
||||||
|
route: BusterRoutes.AUTH_LOGIN
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
openErrorMessage('Error signing out');
|
||||||
|
}
|
||||||
|
}, [onChangePage, openErrorMessage]);
|
||||||
|
|
||||||
return handleSignOut;
|
return handleSignOut;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue