From f6ba3dff5e3de2ed5f6d68d4dd7bbd3ea097fdba Mon Sep 17 00:00:00 2001 From: josedario87 Date: Mon, 13 Oct 2025 01:40:49 -0600 Subject: [PATCH] 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. --- docker-compose.yml | 2 +- nuxt4/app/composables/useAuthentik.ts | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5d989df..b16ca66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: - "traefik.http.services.${APP_NAME}.loadbalancer.server.port=3000" # 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.tls.certresolver=letsencrypt" - "traefik.http.routers.${APP_NAME}-public.priority=100" diff --git a/nuxt4/app/composables/useAuthentik.ts b/nuxt4/app/composables/useAuthentik.ts index 4308af4..51d13cb 100644 --- a/nuxt4/app/composables/useAuthentik.ts +++ b/nuxt4/app/composables/useAuthentik.ts @@ -75,14 +75,6 @@ export const useAuthentik = () => { icon: 'i-heroicons-check-circle', 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 { // Sin sesión en Authentik toast.add({ @@ -92,11 +84,6 @@ export const useAuthentik = () => { icon: 'i-heroicons-exclamation-triangle', timeout: 5000 }) - - // Limpiar state local si está desincronizado - if (authentikUser.value) { - authentikUser.value = null - } } } catch (error) { // Error al consultar