From 5ff106e910544788bc916626ae7665cb26e5af30 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Fri, 11 Oct 2024 20:55:36 -0400
Subject: Provide a separate "initial setup" endpoint that creates a user.

---
 ui/lib/components/LogIn.svelte | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

(limited to 'ui/lib/components/LogIn.svelte')

diff --git a/ui/lib/components/LogIn.svelte b/ui/lib/components/LogIn.svelte
index e1cda8a..bb80ccd 100644
--- a/ui/lib/components/LogIn.svelte
+++ b/ui/lib/components/LogIn.svelte
@@ -1,27 +1,12 @@
 <script>
-    import { goto } from '$app/navigation';
-    import { logIn } from '$lib/apiServer';
-    import { currentUser } from '$lib/store';
-
-    let disabled = false;
-    let username = '';
-    let password = '';
-
-    async function handleLogin() {
-        disabled = true;
-        const response = await logIn(username, password);
-        if (200 <= response.status && response.status < 300) {
-            currentUser.update(() => ({ username }));
-            username = '';
-            password = '';
-            goto('/');
-        }
-        disabled = false;
-    }
+    export let disabled = false;
+    export let username = '';
+    export let password = '';
+    export let legend = 'sign in';
 </script>
 
 <div class="card m-4 p-4">
-    <form on:submit|preventDefault={handleLogin}>
+    <form on:submit|preventDefault>
         <label class="label" for="username">
             username
             <input class="input" name="username" type="text" placeholder="username" bind:value={username} disabled={disabled}>
@@ -31,7 +16,7 @@
             <input class="input" name="password" type="password" placeholder="password" bind:value={password} disabled={disabled}>
         </label>
         <button class="btn variant-filled" type="submit">
-            sign in or up
+            {legend}
         </button>
     </form>
 </div>
-- 
cgit v1.2.3

