fix: resolve auth initialization race and username flicker on login

Always initialize auth before mounting the app so loading state completes
and onAuthStateChange is registered on every route. Gate header auth UI
on !loading to avoid flicker during email confirm and password reset
flows. Load profile before setting user ref so displayUsername shows the
correct name immediately instead of flashing the email.
This commit is contained in:
2026-05-24 16:25:26 +08:00
parent 85471274ab
commit 6fadd63336
3 changed files with 55 additions and 50 deletions
+2 -7
View File
@@ -14,12 +14,7 @@ app.use(pinia)
const authStore = useAuthStore()
if (['/auth/confirm', '/auth/reset-password'].includes(window.location.pathname)) {
authStore.initialize().then(() => {
app.use(router)
app.mount('#app')
} else {
authStore.initialize().then(() => {
app.use(router)
app.mount('#app')
})
}
})