summaryrefslogtreecommitdiff
path: root/ui/routes/(login)/login/+page.svelte
blob: a3496605942b813a7022eaa7264b86c0045f162c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script>
    import { goto } from '$app/navigation';
    import { logIn } from '$lib/apiServer';
    import { currentUser } from '$lib/store';

    import LogIn from '$lib/components/LogIn.svelte';

    let disabled;
    let username;
    let password;

    async function onSubmit() {
        debugger;
        disabled = true;
        const response = await logIn(username, password);
        if (200 <= response.status && response.status < 300) {
            currentUser.update(() => ({ username }));
            username = '';
            password = '';
            goto('/');
        }
        disabled = false;
    }
</script>

<LogIn bind:disabled bind:username bind:password on:submit={onSubmit} />