summaryrefslogtreecommitdiff
path: root/hi-ui/src/lib/LogOut.svelte
blob: 0f0bb1303e2a5d7691b4e102994d07110c32e3e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script>
    import { logOut} from '../apiServer';
    import { currentUser } from '../store';

    async function handleLogout(event) {
        const response = await logOut();
        if (200 <= response.status && response.status < 300) {
            currentUser.update(() => null);
        }
    }
</script>

<form on:submit|preventDefault={handleLogout}>
    @{$currentUser.username}
    <button
        class="border-slate-500 border-solid border-2 font-bold p-1 rounded"
        type="submit"
    >log out</button>
</form>

<style>
</style>