From d31a715974502a7019af8f5cda32218dc1d7f2d4 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Sun, 12 Oct 2025 03:16:01 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20agregar=20dropdown=20de=20autenticaci?= =?UTF-8?q?=C3=B3n=20con=20opci=C3=B3n=20de=20logout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dropdown aparece al hacer click cuando estás conectado - Opciones: verificar estado y cerrar sesión - Logout usa endpoint de Authentik (/outpost.goauthentik.io/sign_out) - Desregistra Service Worker antes de logout - Animación smooth del dropdown - Flecha indicadora que rota al abrir/cerrar - Diseño glassmorphism consistente con la app --- components/AuthIndicator.client.vue | 227 +++++++++++++++++++++++++--- composables/useAuth.ts | 13 ++ 2 files changed, 222 insertions(+), 18 deletions(-) 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