diff --git a/src/composables/useAuth.ts b/src/composables/useAuth.ts index 1bb91c9..0e9d2f9 100644 --- a/src/composables/useAuth.ts +++ b/src/composables/useAuth.ts @@ -29,6 +29,12 @@ export function useAuth() { const currentUser = await account.get(); user.value = currentUser; + } catch (error) { + if (import.meta.env.DEV) { + console.error(error); + } + + user.value = null; } finally { loadingUserFinished.value = true; } diff --git a/src/guards/auth.ts b/src/guards/auth.ts index 9b13dc4..2c5a1e6 100644 --- a/src/guards/auth.ts +++ b/src/guards/auth.ts @@ -8,13 +8,7 @@ export async function authGuard( ) { const { isLoggedIn, loadUser } = useAuth(); - try { - await loadUser(); - } catch (error) { - if (import.meta.env.DEV) { - console.error(error); - } - } + await loadUser(); if (!to.meta.authRequired || isLoggedIn.value) { return next();