RED-6713: change switch accounts flow
This commit is contained in:
parent
6e1d7c1747
commit
d12b5cd76d
@ -14,7 +14,6 @@
|
||||
</ng-container>
|
||||
|
||||
<a (click)="selectTenant()" mat-menu-item>
|
||||
<mat-icon svgIcon="red:open-in-new"></mat-icon>
|
||||
<span translate="top-bar.navigation-items.my-account.children.join-another-tenant"> </span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { BASE_HREF, getCurrentUser, IStoredTenant, TenantsService } from '@iqser/common-ui';
|
||||
import { BASE_HREF, getConfig, getCurrentUser, IStoredTenant, KeycloakStatusService, TenantsService } from '@iqser/common-ui';
|
||||
import { User } from '@red/domain';
|
||||
import { KeyValue } from '@angular/common';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tenants-menu',
|
||||
@ -12,7 +13,10 @@ export class TenantsMenuComponent {
|
||||
readonly tenantsService = inject(TenantsService);
|
||||
readonly storedTenants: Map<string, IStoredTenant[]>;
|
||||
readonly #baseHref = inject(BASE_HREF);
|
||||
readonly #keycloakService = inject(KeycloakService);
|
||||
readonly #keycloakStatusService = inject(KeycloakStatusService);
|
||||
readonly #currentUser = getCurrentUser<User>();
|
||||
readonly #config = getConfig();
|
||||
|
||||
constructor() {
|
||||
this.storedTenants = this.#getStoredTenants();
|
||||
@ -22,11 +26,21 @@ export class TenantsMenuComponent {
|
||||
return item.key;
|
||||
}
|
||||
|
||||
selectTenant(tenantId?: string, email?: string) {
|
||||
let tenantUrl = tenantId ? '/' + tenantId + '/main' : '/';
|
||||
async selectTenant(tenantId?: string, email?: string) {
|
||||
let tenantUrl = tenantId ? '/' + tenantId : '/';
|
||||
if (email) {
|
||||
tenantUrl += '?username=' + email;
|
||||
}
|
||||
|
||||
if (tenantId === this.tenantsService.activeTenantId) {
|
||||
const url = this.#keycloakService.getKeycloakInstance().createLoginUrl({
|
||||
redirectUri: this.#keycloakStatusService.createLoginUrl(),
|
||||
idpHint: this.#config.OAUTH_IDP_HINT,
|
||||
loginHint: email ?? undefined,
|
||||
});
|
||||
return this.#keycloakService.logout(url);
|
||||
}
|
||||
|
||||
window.open(window.location.origin + this.#baseHref + tenantUrl, '_blank');
|
||||
}
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 1522d08a32288e82f2100796e60502c8127850c0
|
||||
Subproject commit 39b4ff1f97c06fed2e0752904bae1ab4f241fb3d
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "redaction",
|
||||
"version": "4.102.0",
|
||||
"version": "4.125.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user