handled tenant change across open tabs.

This commit is contained in:
Diamantis Tziotzios 2024-06-07 16:25:28 +03:00
parent 8940394aa5
commit 050a72e8c7
1 changed files with 10 additions and 1 deletions

View File

@ -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);
}
});
}