diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-11 15:52:42 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-11 15:52:42 -0400 |
| commit | d33c8af14c4adc1c15ab048299e06f9f35ae4de6 (patch) | |
| tree | 5dce8c28876353893dfd4725dcd093afff7e6dff /ui/lib/components/LogOut.svelte | |
| parent | 7bcfeb08946e64642b33f4b099ff235ba8527697 (diff) | |
| parent | 72f3d8c5ab3e2a42cf1a76d0c08815dbe46e50a1 (diff) | |
Merge branch 'wip/login-route'
Diffstat (limited to 'ui/lib/components/LogOut.svelte')
| -rw-r--r-- | ui/lib/components/LogOut.svelte | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/lib/components/LogOut.svelte b/ui/lib/components/LogOut.svelte index 01bef1b..ba0861a 100644 --- a/ui/lib/components/LogOut.svelte +++ b/ui/lib/components/LogOut.svelte @@ -1,17 +1,21 @@ <script> + import { goto } from '$app/navigation'; import { logOut} from '$lib/apiServer'; import { currentUser } from '$lib/store'; - async function handleLogout(event) { + async function handleLogout() { const response = await logOut(); if (200 <= response.status && response.status < 300) { currentUser.update(() => null); + goto('/login'); } } </script> <form on:submit|preventDefault={handleLogout}> - @{$currentUser.username} + {#if $currentUser} + @{$currentUser.username} + {/if} <button class="border-slate-500 border-solid border-2 font-bold p-1 rounded" type="submit" |
