diff --git a/components/AuthIndicator.client.vue b/components/AuthIndicator.client.vue index 277dfb6..be44064 100644 --- a/components/AuthIndicator.client.vue +++ b/components/AuthIndicator.client.vue @@ -1,23 +1,53 @@ diff --git a/composables/useAuth.ts b/composables/useAuth.ts index 89b8c24..aeae531 100644 --- a/composables/useAuth.ts +++ b/composables/useAuth.ts @@ -106,6 +106,18 @@ export const useAuth = () => { window.location.href = window.location.origin + '/' } + const logout = async () => { + console.log('[Auth] Logging out...') + + // Marcar como no autenticado y desregistrar SW + await markUnauthenticated() + + // Navegar al endpoint de logout de Authentik + // Esto cerrará la sesión y redirigirá al login + console.log('[Auth] Navigating to Authentik logout endpoint...') + window.location.href = '/outpost.goauthentik.io/sign_out' + } + const markUnauthenticated = async () => { // Helper para marcar como no autenticado (útil cuando detectamos 401/403) console.log('[Auth] Marking as unauthenticated') @@ -188,6 +200,7 @@ export const useAuth = () => { authStatus, checkAuth, triggerAuth, + logout, markUnauthenticated, setupVisibilityListener, cleanupListeners