fix: desregistrar Service Worker al perder autenticación
All checks were successful
build-and-deploy / build (push) Successful in 23s
build-and-deploy / deploy (push) Successful in 3s

- Desregistrar SW automáticamente cuando se detecta pérdida de auth
- Desregistrar SW antes de triggerAuth para evitar conflictos con Authentik
- Deshabilitar polling y listeners de visibility (causan errores de CORS)
- Confiar en detección reactiva de errores del musicStore
- Usar window.location.href en lugar de reload() para forzar navegación
This commit is contained in:
2025-10-12 03:12:03 -06:00
parent fda5b2497a
commit cda4722a27
2 changed files with 50 additions and 13 deletions

View File

@@ -37,22 +37,25 @@ const musicStore = useMusicStore()
// Check auth on mount and setup listeners
onMounted(async () => {
// Asumimos autenticado inicialmente (si la página cargó, pasamos Authentik)
// Solo verificamos para confirmar
await checkAuth(false)
// NO hacemos checkAuth inicial para evitar conflictos con Service Worker y Authentik
console.log('[AuthIndicator] Mounted - assuming authenticated (page loaded successfully)')
setupVisibilityListener()
// Polling más inteligente: solo si estamos autenticados
// POLLING DESHABILITADO: Causa conflictos con Authentik cuando no estamos autenticados
// En su lugar, confiamos en la detección reactiva de errores del musicStore
console.log('[AuthIndicator] Polling disabled - relying on reactive error detection')
/* CÓDIGO DESHABILITADO
const interval = setInterval(() => {
if (!document.hidden && isAuthenticated.value) {
// Solo hace polling si creemos estar autenticados
// Evita spam de requests cuando ya sabemos que no estamos autenticados
checkAuth(false)
}
}, 60000) // 60 segundos (menos agresivo)
}, 60000)
onUnmounted(() => {
clearInterval(interval)
})
*/
})
// Cleanup listeners on unmount