fix: mejorar detección de pérdida de autenticación con Authentik
- Detectar errores "Failed to fetch" y "no response" como pérdida de auth - Mejor logging para debugging de cambios de estado - Manejar correctamente redirects 302 de Authentik en fetch
This commit is contained in:
@@ -66,8 +66,16 @@ watch(() => musicStore.error, (error, oldError) => {
|
||||
if (error && error !== oldError) {
|
||||
console.log('[AuthIndicator] Music store error detected:', error)
|
||||
|
||||
if (error.includes('401') || error.includes('403') ||
|
||||
error.includes('Unauthorized') || error.includes('Forbidden')) {
|
||||
// Detectar errores de autenticación (múltiples formas)
|
||||
const isAuthError =
|
||||
error.includes('401') ||
|
||||
error.includes('403') ||
|
||||
error.includes('Unauthorized') ||
|
||||
error.includes('Forbidden') ||
|
||||
error.includes('Failed to fetch') || // Authentik redirect genera esto
|
||||
error.includes('no response') // Nuxt $fetch sin respuesta
|
||||
|
||||
if (isAuthError) {
|
||||
// Auth error detected - mark as unauthenticated immediately
|
||||
console.log('[AuthIndicator] Auth error detected, updating status')
|
||||
markUnauthenticated()
|
||||
@@ -80,8 +88,15 @@ watch(() => musicStore.loading, (loading, wasLoading) => {
|
||||
if (wasLoading && !loading && musicStore.error) {
|
||||
// Terminó de cargar con error, verificar si es de auth
|
||||
const error = musicStore.error
|
||||
if (error.includes('401') || error.includes('403') ||
|
||||
error.includes('Unauthorized') || error.includes('Forbidden')) {
|
||||
const isAuthError =
|
||||
error.includes('401') ||
|
||||
error.includes('403') ||
|
||||
error.includes('Unauthorized') ||
|
||||
error.includes('Forbidden') ||
|
||||
error.includes('Failed to fetch') ||
|
||||
error.includes('no response')
|
||||
|
||||
if (isAuthError) {
|
||||
markUnauthenticated()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user