diff --git a/nginx.conf b/nginx.conf index 4c46b13..f7d5319 100644 --- a/nginx.conf +++ b/nginx.conf @@ -12,7 +12,7 @@ server { gzip_types text/css application/javascript application/json image/svg+xml; gzip_min_length 1024; - location ~ ^/(api|imports|data|cacu|cama|tea|governance|reportes|health)(/|$) { + location ~ ^/(api|auth|imports|data|cacu|cama|tea|governance|reportes|health)(/|$) { proxy_pass http://webapi:5000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/proxy.conf.json b/proxy.conf.json index 9890b3c..243b14e 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -1,5 +1,6 @@ { "/api": { "target": "http://localhost:5050", "secure": false, "changeOrigin": true }, + "/auth": { "target": "http://localhost:5050", "secure": false, "changeOrigin": true }, "/imports": { "target": "http://localhost:5050", "secure": false, "changeOrigin": true }, "/data": { "target": "http://localhost:5050", "secure": false, "changeOrigin": true }, "/health": { "target": "http://localhost:5050", "secure": false, "changeOrigin": true }, diff --git a/src/app/app-encabezado.spec.ts b/src/app/app-encabezado.spec.ts index 24ab7a6..2d3d2b8 100644 --- a/src/app/app-encabezado.spec.ts +++ b/src/app/app-encabezado.spec.ts @@ -37,7 +37,8 @@ describe('Encabezado del marco', () => { it('las rutas de los tres dominios existen en el enrutador de la aplicación', () => { // Fails if the selector would point at a route the application does not have. - const paths = routes.map(r => r.path); + // The application's routes live under the guarded parent ('login' is its sibling). + const paths = routes.flatMap((ruta) => [ruta.path, ...(ruta.children ?? []).map((hijo) => hijo.path)]); for (const dominio of DOMINIOS) expect(paths).toContain(`indicadores/${dominio}`); }); it.each([['tea', 'TEA'], ['cacu', 'CaCu'], ['cama', 'Cáncer de mama']] as const)('en /indicadores/%s muestra el título de la plataforma y el selector con «%s»', async (dominio, etiqueta) => { diff --git a/src/app/app.config.ts b/src/app/app.config.ts index a8b7623..69f1168 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,7 +1,8 @@ import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core'; -import { provideHttpClient } from '@angular/common/http'; +import { provideHttpClient, withInterceptors } from '@angular/common/http'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; +import { authInterceptor } from './auth/auth.interceptor'; import { IndicadoresService } from './features/indicadores/indicadores.service'; import { IndicadoresPeriodos } from './features/indicadores/indicadores-periodos'; import { TeaSeguimientoService } from './features/indicadores/tea-seguimiento.service'; @@ -12,7 +13,8 @@ export const appConfig: ApplicationConfig = { providers: [ provideBrowserGlobalErrorListeners(), provideRouter(routes), - provideHttpClient(), + // `authInterceptor` regresa al inicio de sesión cuando el servidor responde 401. + provideHttpClient(withInterceptors([authInterceptor])), // The indicator page reads the WebApi's FHIR endpoint; without these lines it reads the indicator JSON contract // (`//indicadores//datos`, `/tea/seguimiento`). { provide: IndicadoresService, useClass: FhirIndicadoresService }, diff --git a/src/app/app.html b/src/app/app.html index 7312335..b4ff016 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -1,33 +1,52 @@
- + } @else { + + } + @if (usuario(); as sesion) { + + } +
+ + }
- @if (!workspace()) { + @if (!workspace() && !sinCromo()) {