diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-11-09 22:55:22 -0500 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-11-09 22:55:22 -0500 |
| commit | 24eb775ba77f5a6a78a299d9fdffb34f8f167f8d (patch) | |
| tree | 32ab5163d55688dd90dc796aa44d94fec0b35c81 /ui/lib/components/LogOut.svelte | |
| parent | 91ce856f63bd1d7a188488476bdbec60b5bd58ff (diff) | |
| parent | a417c62edd4d3c07ba37b01835e89ed650489e09 (diff) | |
Merge branch 'main' into wip/touch-events
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> |
