From 0b5514f376a04bc521139dd53d3e43ab1d321621 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 24 Apr 2025 03:16:46 +0900 Subject: [PATCH] refac --- src/routes/+layout.svelte | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 0bbe25046..851b7c899 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -34,7 +34,7 @@ import { Toaster, toast } from 'svelte-sonner'; import { executeToolServer, getBackendConfig } from '$lib/apis'; - import { getSessionUser } from '$lib/apis/auths'; + import { getSessionUser, userSignOut } from '$lib/apis/auths'; import '../tailwind.css'; import '../app.css'; @@ -444,7 +444,7 @@ } }; - const checkTokenExpiry = () => { + const checkTokenExpiry = async () => { const exp = $user?.expires_at; // token expiry time in unix timestamp const now = Math.floor(Date.now() / 1000); // current time in unix timestamp @@ -454,11 +454,11 @@ } if (now >= exp) { + await userSignOut(); + user.set(null); + localStorage.removeItem('token'); - // redirect to auth page - if ($page.url.pathname !== '/auth') { - goto(`/auth`); - } + location.href = '/auth'; } };