diff --git a/packages/hoppscotch-selfhost-web/src/platform/auth/auth.platform.ts b/packages/hoppscotch-selfhost-web/src/platform/auth/auth.platform.ts index 6783f60df..c6708bc8f 100644 --- a/packages/hoppscotch-selfhost-web/src/platform/auth/auth.platform.ts +++ b/packages/hoppscotch-selfhost-web/src/platform/auth/auth.platform.ts @@ -114,6 +114,7 @@ async function setInitialUser() { } else { setUser(null) isGettingInitialUser.value = false + await logout() } return @@ -146,22 +147,26 @@ async function setInitialUser() { } async function refreshToken() { - const res = await axios.get( - `${import.meta.env.VITE_BACKEND_API_URL}/auth/refresh`, - { - withCredentials: true, + try { + const res = await axios.get( + `${import.meta.env.VITE_BACKEND_API_URL}/auth/refresh`, + { + withCredentials: true, + } + ) + + const isSuccessful = res.status === 200 + + if (isSuccessful) { + authEvents$.next({ + event: "token_refresh", + }) } - ) - const isSuccessful = res.status === 200 - - if (isSuccessful) { - authEvents$.next({ - event: "token_refresh", - }) + return isSuccessful + } catch (error) { + return false } - - return isSuccessful } async function sendMagicLink(email: string) {