Fix session status check to preserve authentication state

Remove /api/auth/status from public routes so it receives Authentik headers.
Remove logic that was clearing local auth state, which caused the page to
show "No autenticado" even when user was authenticated.

Now the button only displays session status without modifying the UI state.
This commit is contained in:
2025-10-13 01:40:49 -06:00
parent ddea20376d
commit f6ba3dff5e
2 changed files with 1 additions and 14 deletions

View File

@@ -24,7 +24,7 @@ services:
- "traefik.http.services.${APP_NAME}.loadbalancer.server.port=3000" - "traefik.http.services.${APP_NAME}.loadbalancer.server.port=3000"
# Router 1: Public PWA resources (no auth) - Higher priority # Router 1: Public PWA resources (no auth) - Higher priority
- "traefik.http.routers.${APP_NAME}-public.rule=Host(`${APP_DOMAIN}`) && (PathPrefix(`/manifest.webmanifest`) || PathPrefix(`/sw.js`) || PathPrefix(`/workbox-`) || PathPrefix(`/icon-`) || PathPrefix(`/apple-touch-icon`) || PathPrefix(`/favicon.ico`) || PathPrefix(`/robots.txt`) || PathPrefix(`/api/auth/status`))" - "traefik.http.routers.${APP_NAME}-public.rule=Host(`${APP_DOMAIN}`) && (PathPrefix(`/manifest.webmanifest`) || PathPrefix(`/sw.js`) || PathPrefix(`/workbox-`) || PathPrefix(`/icon-`) || PathPrefix(`/apple-touch-icon`) || PathPrefix(`/favicon.ico`) || PathPrefix(`/robots.txt`))"
- "traefik.http.routers.${APP_NAME}-public.entrypoints=websecure" - "traefik.http.routers.${APP_NAME}-public.entrypoints=websecure"
- "traefik.http.routers.${APP_NAME}-public.tls.certresolver=letsencrypt" - "traefik.http.routers.${APP_NAME}-public.tls.certresolver=letsencrypt"
- "traefik.http.routers.${APP_NAME}-public.priority=100" - "traefik.http.routers.${APP_NAME}-public.priority=100"

View File

@@ -75,14 +75,6 @@ export const useAuthentik = () => {
icon: 'i-heroicons-check-circle', icon: 'i-heroicons-check-circle',
timeout: 5000 timeout: 5000
}) })
// Actualizar el state local si está desincronizado
if (!authentikUser.value) {
authentikUser.value = {
...response.user,
avatar: `https://ui-avatars.com/api/?name=${encodeURIComponent(response.user.name || response.user.username)}&background=random&size=128`
}
}
} else { } else {
// Sin sesión en Authentik // Sin sesión en Authentik
toast.add({ toast.add({
@@ -92,11 +84,6 @@ export const useAuthentik = () => {
icon: 'i-heroicons-exclamation-triangle', icon: 'i-heroicons-exclamation-triangle',
timeout: 5000 timeout: 5000
}) })
// Limpiar state local si está desincronizado
if (authentikUser.value) {
authentikUser.value = null
}
} }
} catch (error) { } catch (error) {
// Error al consultar // Error al consultar