From cd3ba9c2773bc97edd9379e27ea91c2df1648781 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sun, 23 Jun 2024 17:31:38 +0200 Subject: Pages: Add logout page --- src/App.tsx | 4 ++++ src/pages/Logout.tsx | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/pages/Logout.tsx diff --git a/src/App.tsx b/src/App.tsx index db216c6..61f7b8b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,6 +5,7 @@ import { createClient } from '@supabase/supabase-js' import Home from './pages/Home' import Login from './pages/Login' +import Logout from './pages/Logout'; const supabase = createClient('https://slpoocycjgqsuoedhkbn.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNscG9vY3ljamdxc3VvZWRoa2JuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTUyMDU0MjUsImV4cCI6MjAzMDc4MTQyNX0.xZYRTRN65rlms1Hb96IBAQvw3EGtMzUxlGPP5TVey34') @@ -20,6 +21,9 @@ function App() { } /> + + } /> notfound

} /> diff --git a/src/pages/Logout.tsx b/src/pages/Logout.tsx new file mode 100644 index 0000000..e480cb0 --- /dev/null +++ b/src/pages/Logout.tsx @@ -0,0 +1,16 @@ +import { useEffect } from 'react' +import { useNavigate } from "react-router-dom"; + +export default function Logout(props: any) { + const navigate = useNavigate(); + + useEffect(() => { + const logout = async () => { + await props.supabase.auth.signOut() + } + logout() + navigate('/login') + }, [props.session]) + + return (<>) +} -- cgit 1.4.1