vamos2
All checks were successful
build-and-deploy / build (push) Successful in 25s
build-and-deploy / deploy (push) Successful in 4s

This commit is contained in:
2025-10-12 02:08:41 -06:00
parent 98fb972a4e
commit bca654dee4
2 changed files with 61 additions and 53 deletions

View File

@@ -36,15 +36,19 @@ const musicStore = useMusicStore()
// Check auth on mount and setup listeners
onMounted(async () => {
await checkAuth(true)
// Asumimos autenticado inicialmente (si la página cargó, pasamos Authentik)
// Solo verificamos para confirmar
await checkAuth(false)
setupVisibilityListener()
// Chequea auth cada 30 segundos mientras la pestaña está activa
// Polling más inteligente: solo si estamos autenticados
const interval = setInterval(() => {
if (!document.hidden) {
checkAuth()
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)
}
}, 30000)
}, 60000) // 60 segundos (menos agresivo)
onUnmounted(() => {
clearInterval(interval)
@@ -104,9 +108,9 @@ const statusText = computed(() => {
case 'authenticated':
return 'Conectado'
case 'unauthenticated':
return 'Sin conexión'
return 'Reautenticar'
default:
return 'Desconocido'
return 'Verificando...'
}
})
@@ -115,11 +119,11 @@ const tooltipText = computed(() => {
switch (authStatus.value) {
case 'authenticated':
return 'Estás autenticado. Puedes descargar música.'
return 'Estás autenticado. Click para verificar estado.'
case 'unauthenticated':
return 'No autenticado. Click para iniciar sesión.'
return 'Sesión expirada. Click para iniciar sesión de nuevo.'
default:
return 'Estado de autenticación desconocido'
return 'Verificando estado de autenticación...'
}
})
@@ -127,11 +131,11 @@ const handleClick = () => {
if (isCheckingAuth.value) return
if (authStatus.value === 'unauthenticated') {
// Redirect to trigger Authentik
// Forzar reload de la página para que Authentik intercepte
triggerAuth()
} else if (authStatus.value === 'authenticated') {
// Re-check auth status
checkAuth()
// Re-check auth status (forzar, ignorar cache)
checkAuth(true)
}
}
</script>