From 72f3d8c5ab3e2a42cf1a76d0c08815dbe46e50a1 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Fri, 11 Oct 2024 01:18:18 -0400
Subject: Move login to its own route.

This - in passing - fixes the problem where the client failed to subscribe after logging in, by causing the whole subscription process to be re-run when returning to the main interface.
---
 ui/lib/components/LogOut.svelte | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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

diff --git a/ui/lib/components/LogOut.svelte b/ui/lib/components/LogOut.svelte
index 01bef1b..ba0861a 100644
--- a/ui/lib/components/LogOut.svelte
+++ b/ui/lib/components/LogOut.svelte
@@ -1,17 +1,21 @@
 <script>
+    import { goto } from '$app/navigation';
     import { logOut} from '$lib/apiServer';
     import { currentUser } from '$lib/store';
 
-    async function handleLogout(event) {
+    async function handleLogout() {
         const response = await logOut();
         if (200 <= response.status && response.status < 300) {
             currentUser.update(() => null);
+            goto('/login');
         }
     }
 </script>
 
 <form on:submit|preventDefault={handleLogout}>
-    @{$currentUser.username}
+    {#if $currentUser}
+        @{$currentUser.username}
+    {/if}
     <button
         class="border-slate-500 border-solid border-2 font-bold p-1 rounded"
         type="submit"
-- 
cgit v1.2.3

