diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-31 11:38:06 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-31 11:38:06 +0100 |
commit | 8d3b8fd8aa9603f5377f1b37963190ac2c01e9dd (patch) | |
tree | 7f4867f47702eedbb94e9723597f301e36aa0ea8 /web/pw-server/src/routes/login.svelte | |
parent | 74d0189d37087188de72a70aadb0e3a22cad7917 (diff) | |
download | planetwars.dev-8d3b8fd8aa9603f5377f1b37963190ac2c01e9dd.tar.xz planetwars.dev-8d3b8fd8aa9603f5377f1b37963190ac2c01e9dd.zip |
npm run format
Diffstat (limited to 'web/pw-server/src/routes/login.svelte')
-rw-r--r-- | web/pw-server/src/routes/login.svelte | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/web/pw-server/src/routes/login.svelte b/web/pw-server/src/routes/login.svelte index 197238e..09b1834 100644 --- a/web/pw-server/src/routes/login.svelte +++ b/web/pw-server/src/routes/login.svelte @@ -1,46 +1,46 @@ <script lang="ts"> - import { get_session_token, set_session_token } from '$lib/auth'; - import { goto } from '$app/navigation'; + import { get_session_token, set_session_token } from "$lib/auth"; + import { goto } from "$app/navigation"; - let username: string | undefined; - let password: string | undefined; + let username: string | undefined; + let password: string | undefined; - const onSubmit = () => { - fetch('/api/login', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - username, - password - }) - }) - .then((response) => { + const onSubmit = () => { + fetch("/api/login", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + username, + password, + }), + }) + .then((response) => { if (!response.ok) { throw Error(response.statusText); } return response.text(); }) - .then((token) => { - set_session_token(token); - goto("/") - }); - }; + .then((token) => { + set_session_token(token); + goto("/"); + }); + }; function loggedIn(): boolean { - return get_session_token() != null + return get_session_token() != null; } </script> {#if loggedIn()} - you are logged in + you are logged in {/if} <form on:submit|preventDefault={onSubmit}> - <label for="username">Username</label> - <input name="username" bind:value={username} /> - <label for="password">Password</label> - <input type="password" name="password" bind:value={password} /> - <button type="submit">Log in</button> + <label for="username">Username</label> + <input name="username" bind:value={username} /> + <label for="password">Password</label> + <input type="password" name="password" bind:value={password} /> + <button type="submit">Log in</button> </form> |