From 03c4509792884ae6fd9ba2185c51cae12e5db05e Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Mon, 6 Mar 2023 09:17:54 +0100 Subject: [PATCH 1/2] clean store onmount if forbidden access --- front/volume/src/Auth.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/front/volume/src/Auth.ts b/front/volume/src/Auth.ts index 9575fa4..69af3d0 100644 --- a/front/volume/src/Auth.ts +++ b/front/volume/src/Auth.ts @@ -20,10 +20,8 @@ export async function getUser() { referrerPolicy: "no-referrer", }); let user = await res.json(); - if (user.username) { - console.log(user); - store.set(user); - } + if (user.username) store.set(user); + else store.set(null); } export function login() { From 5d013a2316de01d9df971db374f7ae13a2e10dc9 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Mon, 6 Mar 2023 10:04:00 +0100 Subject: [PATCH 2/2] refresh user at 15sec interval --- front/volume/src/App.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 0ebb2b6..592b0cd 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -20,6 +20,9 @@ onMount(() => { getUser(); }); + setInterval(() => { + getUser(); + },15000) let isProfileOpen = false; function clickProfile() {