diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-06-23 17:31:38 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-06-23 17:31:38 +0200 |
commit | cd3ba9c2773bc97edd9379e27ea91c2df1648781 (patch) | |
tree | 02da1613f810315deebbd7a1327e65281a650036 | |
parent | Home: Add sidebar (diff) | |
download | fs-tracer-frontend-cd3ba9c2773bc97edd9379e27ea91c2df1648781.tar.gz fs-tracer-frontend-cd3ba9c2773bc97edd9379e27ea91c2df1648781.tar.bz2 fs-tracer-frontend-cd3ba9c2773bc97edd9379e27ea91c2df1648781.zip |
Pages: Add logout page
-rw-r--r-- | src/App.tsx | 4 | ||||
-rw-r--r-- | src/pages/Logout.tsx | 16 |
2 files changed, 20 insertions, 0 deletions
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() { <Route path="login" element={ <Login supabase={supabase} session={session} setSession={setSession} /> } /> + <Route path="logout" element={ + <Logout supabase={supabase} session={session} setSession={setSession} /> + } /> <Route path="*" element={<p>notfound</p>} /> </Routes> </BrowserRouter> 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 (<></>) +} |