mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
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.
This commit is contained in:
@@ -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<boolean>(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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user