RED-6713: update tenant selection
This commit is contained in:
parent
1522d08a32
commit
39b4ff1f97
@ -16,6 +16,8 @@ export const ifLoggedIn: CanActivateFn = async (route: ActivatedRouteSnapshot) =
|
||||
|
||||
const keycloakInstance = keycloakService.getKeycloakInstance();
|
||||
const tenant = route.paramMap.get('tenant');
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
const username = queryParams.get('username');
|
||||
|
||||
if (!keycloakInstance) {
|
||||
if (!tenant) {
|
||||
@ -37,6 +39,6 @@ export const ifLoggedIn: CanActivateFn = async (route: ActivatedRouteSnapshot) =
|
||||
}
|
||||
|
||||
logger.warn('[ROUTES] Redirect to login');
|
||||
await keycloakStatusService.createLoginUrlAndExecute(route.queryParamMap.get('username'));
|
||||
keycloakStatusService.createLoginUrlAndExecute(username);
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, inject, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
import { TenantsService } from '../services';
|
||||
@ -10,6 +10,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
@Component({
|
||||
templateUrl: './tenant-select.component.html',
|
||||
styleUrls: ['./tenant-select.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class TenantSelectComponent {
|
||||
@Input() isLoggedOut = false;
|
||||
@ -19,8 +20,8 @@ export class TenantSelectComponent {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
tenantId: ['', Validators.required],
|
||||
});
|
||||
protected readonly _tenantsService = inject(TenantsService);
|
||||
protected readonly storedTenants = this._tenantsService
|
||||
protected readonly tenantsService = inject(TenantsService);
|
||||
protected readonly storedTenants = this.tenantsService
|
||||
.getStoredTenants()
|
||||
.sort((a, b) => a.tenant.displayName.localeCompare(b.tenant.displayName));
|
||||
protected readonly titleService = inject(Title);
|
||||
@ -33,7 +34,7 @@ export class TenantSelectComponent {
|
||||
throw new Error('No tenant selected!');
|
||||
}
|
||||
|
||||
if (!this._tenantsService.has(tenantId)) {
|
||||
if (!this.tenantsService.has(tenantId)) {
|
||||
this.toaster.error(_('tenant-resolve.tenant-does-not-exist'));
|
||||
return;
|
||||
}
|
||||
@ -45,9 +46,9 @@ export class TenantSelectComponent {
|
||||
}
|
||||
|
||||
#getQueryParams(tenantId: string) {
|
||||
const existingStored = this.storedTenants.find(s => s.tenant.tenantId === tenantId);
|
||||
if (existingStored) {
|
||||
return { username: existingStored.email };
|
||||
const existingStored = this.storedTenants.filter(s => s.tenant.tenantId === tenantId);
|
||||
if (existingStored.length === 1) {
|
||||
return { username: existingStored[0].email };
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user