From 29782aba01b8f34625949170dc9ee9e1c5872893 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 15 Jul 2026 16:26:40 -0400 Subject: [PATCH] refac --- src/routes/+layout.svelte | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index fd2ba32df9..174e431faf 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -843,8 +843,15 @@ } isAuthRedirectInProgress = true; + if (tokenTimer) { + clearInterval(tokenTimer); + tokenTimer = null; + } user.set(null); localStorage.removeItem('token'); + userSignOut().catch((error) => { + console.error('Error signing out expired session:', error); + }); toast.error($i18n.t('Session expired. Please sign in again.')); const currentPath = `${window.location.pathname}${window.location.search}`; @@ -876,11 +883,7 @@ } if (now >= exp - TOKEN_EXPIRY_BUFFER) { - const res = await userSignOut(); - user.set(null); - localStorage.removeItem('token'); - - location.href = res?.redirect_url ?? '/auth'; + redirectToAuthAfterUnauthorized(); } };