From 2b5a80a0324d153b20eac7e6949cc02aea9c1c07 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 22 Mar 2022 18:10:39 +0100 Subject: implement currentUser store --- web/pw-server/src/lib/components/navbar/UserControls.svelte | 13 +++++++------ web/pw-server/src/lib/stores/current_user.ts | 3 +++ web/pw-server/src/routes/login.svelte | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 web/pw-server/src/lib/stores/current_user.ts (limited to 'web/pw-server') diff --git a/web/pw-server/src/lib/components/navbar/UserControls.svelte b/web/pw-server/src/lib/components/navbar/UserControls.svelte index e9dbab1..3c1d181 100644 --- a/web/pw-server/src/lib/components/navbar/UserControls.svelte +++ b/web/pw-server/src/lib/components/navbar/UserControls.svelte @@ -1,11 +1,11 @@
- {#if user} + {#if $currentUser}
- {user["username"]} + {$currentUser["username"]}
Sign out
{:else} diff --git a/web/pw-server/src/lib/stores/current_user.ts b/web/pw-server/src/lib/stores/current_user.ts new file mode 100644 index 0000000..ac53070 --- /dev/null +++ b/web/pw-server/src/lib/stores/current_user.ts @@ -0,0 +1,3 @@ +import { writable } from "svelte/store"; + +export const currentUser = writable(null); diff --git a/web/pw-server/src/routes/login.svelte b/web/pw-server/src/routes/login.svelte index 9ff0378..911635b 100644 --- a/web/pw-server/src/routes/login.svelte +++ b/web/pw-server/src/routes/login.svelte @@ -1,6 +1,7 @@ -

Sign in

@@ -49,7 +50,6 @@
- \ No newline at end of file + -- cgit v1.2.3