diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-11-06 17:42:02 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-11-07 19:09:36 -0500 |
| commit | 9f0ba2e243be772a7677f8250893f5da7b2acbfe (patch) | |
| tree | 3996d527e06a525a1531c095478cd3c02bbae3bb /ui/lib/components/LogOut.svelte | |
| parent | b89ffe00fbb28fac3daafb1f7adc71be72b59433 (diff) | |
Factor out the elements of the `/me` page, and style them a little.
Diffstat (limited to 'ui/lib/components/LogOut.svelte')
| -rw-r--r-- | ui/lib/components/LogOut.svelte | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/lib/components/LogOut.svelte b/ui/lib/components/LogOut.svelte new file mode 100644 index 0000000..25dd5e9 --- /dev/null +++ b/ui/lib/components/LogOut.svelte @@ -0,0 +1,18 @@ +<script> + import { goto } from '$app/navigation'; + import { logOut } from '$lib/apiServer.js'; + import { currentUser } from '$lib/store'; + + async function onsubmit(event) { + event.preventDefault(); + const response = await logOut(); + if (200 <= response.status && response.status < 300) { + currentUser.update(() => null); + goto('/login'); + } + } +</script> + +<form {onsubmit}> + <button class="btn bg-orange-400" type="submit">log out</button> +</form> |
