From 6abeb70c92066d24a8576dde6e7b807e8034ad36 Mon Sep 17 00:00:00 2001 From: Dennis960 <66166638+Dennis960@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:31:43 +0000 Subject: [PATCH] Automate login, Add logout button --- Blumy-Server/src/routes/+layout.server.ts | 7 +++++++ Blumy-Server/src/routes/+layout.svelte | 13 ++++++++++++ Blumy-Server/src/routes/login/+page.svelte | 24 +++++++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 Blumy-Server/src/routes/+layout.server.ts diff --git a/Blumy-Server/src/routes/+layout.server.ts b/Blumy-Server/src/routes/+layout.server.ts new file mode 100644 index 0000000..266f7c8 --- /dev/null +++ b/Blumy-Server/src/routes/+layout.server.ts @@ -0,0 +1,7 @@ +import type { LayoutServerLoad } from "./$types"; + +export const load = (({ locals }) => { + return { + authenticated: locals.user !== null + } +}) satisfies LayoutServerLoad; \ No newline at end of file diff --git a/Blumy-Server/src/routes/+layout.svelte b/Blumy-Server/src/routes/+layout.svelte index 2b4c58b..ea6508b 100644 --- a/Blumy-Server/src/routes/+layout.svelte +++ b/Blumy-Server/src/routes/+layout.svelte @@ -8,6 +8,8 @@ import { pwaInfo } from 'virtual:pwa-info'; import { PUBLIC_MODE } from '$env/static/public'; + export let data; + onMount(async () => { // @ts-expect-error no declaration file await import('@tabler/core/dist/js/tabler.js'); @@ -47,6 +49,17 @@ + {#if data.authenticated} +
+ {/if}