diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index 1abcd36ce..2e04bdd80 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -16,6 +16,7 @@ import { ConfigurationService } from '../configuration/configuration.service'; import { PrincipalService } from '../http/principal.service'; import { BaseHttpParams } from '@common/http/base-http-params'; import { InterceptorType } from '@common/http/interceptors/interceptor-type'; +import { TenantHandlingService } from '../tenant/tenant-handling.service'; export interface ResolutionContext { roles: AppRole[]; @@ -48,7 +49,8 @@ export class AuthService extends BaseService { private zone: NgZone, private keycloakService: KeycloakService, private uiNotificationService: UiNotificationService, - private principalService: PrincipalService + private principalService: PrincipalService, + private tenantHandlingService: TenantHandlingService, ) { super(); @@ -67,6 +69,13 @@ export class AuthService extends BaseService { this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: this.router.url }, }); + } else if ( + event.key && + event.key === 'selectedTenant' && + event.newValue != this.selectedTenant() + ) { + this.selectedTenant(event.newValue); + window.location.href = this.tenantHandlingService.getCurrentUrlEnrichedWithTenantCode(event.newValue, true); } }); }