From b70f2798df277db1253a7615083c9d9dfc70224c Mon Sep 17 00:00:00 2001 From: Lorenz Hilpert Date: Wed, 12 Nov 2025 15:58:38 +0100 Subject: [PATCH] fix(auth): Use Angular Router for post-auth redirects Replace window.location.href with Router.navigateByUrl() to ensure proper Angular navigation flow after authentication, maintaining state and avoiding full page reloads. --- apps/isa-app/src/core/auth/auth.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/isa-app/src/core/auth/auth.service.ts b/apps/isa-app/src/core/auth/auth.service.ts index 4c67d8826..6d7922ecc 100644 --- a/apps/isa-app/src/core/auth/auth.service.ts +++ b/apps/isa-app/src/core/auth/auth.service.ts @@ -1,11 +1,12 @@ import { coerceArray } from '@angular/cdk/coercion'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Config } from '@core/config'; import { isNullOrUndefined } from '@utils/common'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks'; import { BehaviorSubject } from 'rxjs'; import { logger } from '@isa/core/logging'; +import { Router } from '@angular/router'; /** * Storage key for the URL to redirect to after login @@ -17,6 +18,7 @@ const REDIRECT_URL_KEY = 'auth_redirect_url'; }) export class AuthService { #logger = logger(() => ({ service: 'AuthService' })); + #router = inject(Router); #initialized = new BehaviorSubject(false); get initialized$() { @@ -48,7 +50,8 @@ export class AuthService { this.#logger.debug('Redirecting after authentication', () => ({ redirectUrl, })); - window.location.href = redirectUrl; + + this.#router.navigateByUrl(redirectUrl); } }, 100); }