Files
harheimertc/plugins/auth-sync.client.js
Torsten Schulz (local) 3586704cce
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 10m29s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped
Update file permissions for multiple server and test files to executable mode
2026-07-15 08:45:12 +02:00

25 lines
538 B
JavaScript
Executable File

export default defineNuxtPlugin((nuxtApp) => {
const authStore = useAuthStore()
const syncAuthState = async () => {
await authStore.checkAuth()
}
nuxtApp.hook('app:mounted', () => {
syncAuthState()
})
if (typeof window !== 'undefined') {
window.addEventListener('pageshow', (event) => {
if (event.persisted) {
syncAuthState()
}
})
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
syncAuthState()
}
})
}
})