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/routes/(login)/login/+page.svelte | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

(limited to 'ui/routes/(login)/login/+page.svelte')

diff --git a/ui/routes/(login)/login/+page.svelte b/ui/routes/(login)/login/+page.svelte
index c333fdd..a349660 100644
--- a/ui/routes/(login)/login/+page.svelte
+++ b/ui/routes/(login)/login/+page.svelte
@@ -1,5 +1,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 />
+<LogIn bind:disabled bind:username bind:password on:submit={onSubmit} />
-- 
cgit v1.2.3

