Browse Source

Add logout

Daniel Bohry 1 year ago
parent
commit
ff554f7000
3 changed files with 34 additions and 2 deletions
  1. 1 2
      src/routes/login/+page.svelte
  2. 9 0
      src/routes/logout/+page.js
  3. 24 0
      src/routes/logout/+page.svelte

+ 1 - 2
src/routes/login/+page.svelte

@@ -68,8 +68,7 @@
     }
 
     function logout() {
-        auth.set(null);
-        localStorage.removeItem('auth');
+        window.location.href = "/logout";
     }
 
     function navigateToRegister() {

+ 9 - 0
src/routes/logout/+page.js

@@ -0,0 +1,9 @@
+import { dev } from '$app/environment';
+
+// we don't need any JS on this page, though we'll load
+// it in dev so that we get hot module replacement
+export const csr = dev;
+
+// since there's no dynamic data here, we can prerender
+// it so that it gets served as a static asset in production
+export const prerender = true;

+ 24 - 0
src/routes/logout/+page.svelte

@@ -0,0 +1,24 @@
+<script>
+    import {onMount} from "svelte";
+    import {auth} from '../store.js';
+
+    function logout() {
+        auth.set(null);
+        localStorage.removeItem('auth');
+        window.location.href = "/login";
+    }
+
+    onMount(() => {
+        logout();
+    });
+</script>
+
+<svelte:head>
+    <title>Logout</title>
+    <meta name="description" content="Logout page"/>
+</svelte:head>
+
+<div class="text-column">
+    <p>Logging you out...</p>
+    <p>Please wait...</p>
+</div>