Fix timezone resetting to UTC on page reload

On reload, the access token existed in localStorage so isAuthenticated
was true, but user.value was null — fetchMe was never called, so
authStore.timezone fell back to 'UTC' before the component mounted.

Router guard now calls fetchMe() when authenticated but user data is
not yet loaded, ensuring user preferences are available to all
auth-required pages on the first render after a reload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 21:13:05 -08:00
parent 63230149c5
commit 4a14f8b3f1

View File

@@ -52,6 +52,9 @@ router.beforeEach(async (to) => {
if (!auth.isAuthenticated) {
return { name: 'login', query: { redirect: to.fullPath } }
}
} else if (!auth.user) {
// Token exists but user data not loaded yet (e.g. page reload) — fetch it now
await auth.fetchMe()
}
}
})