summaryrefslogtreecommitdiff
path: root/ui/routes/(login)/login/+page.svelte
blob: 77c2d62a4bf46ea9d429299d6b274f4685aa16bf (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
<script>
	import { goto } from '$app/navigation';
	import { logIn } from '$lib/apiServer';

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

	let username = '',
		password = '';
	let pending = false;
	$: disabled = pending;

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

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