From 13ca1d1432e64540b4406d6ed35e653e2219c880 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 16 Aug 2023 20:42:54 +0200 Subject: [PATCH] Added login --- src/app.html | 22 +++++------ src/{app.pcss => app.postcss} | 0 src/routes/+layout.svelte | 47 ++++++++++++++++++++---- src/routes/+page.svelte | 19 ++++++++-- src/routes/account/+layout.svelte | 39 ++++++++++++-------- src/routes/account/login/Login.svelte | 24 ++++++++++-- src/routes/account/register/+page.svelte | 4 +- src/serverrequest.js | 3 +- 8 files changed, 115 insertions(+), 43 deletions(-) rename src/{app.pcss => app.postcss} (100%) diff --git a/src/app.html b/src/app.html index 83c1951..dcf03f9 100644 --- a/src/app.html +++ b/src/app.html @@ -1,12 +1,12 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ diff --git a/src/app.pcss b/src/app.postcss similarity index 100% rename from src/app.pcss rename to src/app.postcss diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6c6fb33..503108b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,11 +1,44 @@ +{#if typeof globalvars.user !== 'undefined' } + {#each alertsvar as alert, i} + + {/each} +{/if} + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index deedc03..0e18dde 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,9 +1,22 @@ \ No newline at end of file + onMount(async () => { + if(typeof globalvars.user === 'undefined') { + goto("/account/login"); + } + }); + + + +{#if typeof globalvars.user !== 'undefined'} +

Welcome {globalvars.user.name}

+{/if} \ No newline at end of file diff --git a/src/routes/account/+layout.svelte b/src/routes/account/+layout.svelte index 9beaf55..527d9ff 100644 --- a/src/routes/account/+layout.svelte +++ b/src/routes/account/+layout.svelte @@ -1,20 +1,23 @@

Blackbird Chess

- {#each alertsvar as alert, i} - - {/each} - - + {#if typeof globalvars.user == 'undefined' } + {#each alertsvar as alert, i} + + {/each} + {/if} +
+ +
@@ -23,9 +26,11 @@ \ No newline at end of file diff --git a/src/routes/account/login/Login.svelte b/src/routes/account/login/Login.svelte index 75fa568..35aee88 100644 --- a/src/routes/account/login/Login.svelte +++ b/src/routes/account/login/Login.svelte @@ -3,7 +3,7 @@