Files
frontend/app/plugins/auth.client.ts
T

14 lines
296 B
TypeScript

export default defineNuxtPlugin(async () => {
const auth = useAuth()
if ((auth.token.value || auth.tokenState.value) && !auth.user.value) {
try {
await auth.syncUser()
} catch (error) {
console.error('[Auth Plugin] Sync failed:', error)
auth.logout()
}
}
})