feat: agregar dropdown de autenticación con opción de logout
- 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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user