RED-3800: fix keycloak query params removal
This commit is contained in:
parent
1505dac3ac
commit
8810ae218d
@ -51,7 +51,7 @@
|
|||||||
"project": "./tsconfig.json"
|
"project": "./tsconfig.json"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"rxjs/no-ignored-subscription": "error",
|
"rxjs/no-ignored-subscription": "warn",
|
||||||
"@angular-eslint/no-conflicting-lifecycle": "error",
|
"@angular-eslint/no-conflicting-lifecycle": "error",
|
||||||
"@angular-eslint/no-host-metadata-property": "error",
|
"@angular-eslint/no-host-metadata-property": "error",
|
||||||
"@angular-eslint/no-input-rename": "error",
|
"@angular-eslint/no-input-rename": "error",
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { Component, inject, OnDestroy, Renderer2, ViewContainerRef } from '@angular/core';
|
import { Component, inject, Renderer2, ViewContainerRef } from '@angular/core';
|
||||||
import { RouterHistoryService } from '@services/router-history.service';
|
import { RouterHistoryService } from '@services/router-history.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { UserPreferenceService } from '@users/user-preference.service';
|
import { UserPreferenceService } from '@users/user-preference.service';
|
||||||
import { getConfig } from '@iqser/common-ui';
|
import { getConfig } from '@iqser/common-ui';
|
||||||
import { AppConfig } from '@red/domain';
|
import { AppConfig } from '@red/domain';
|
||||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { filter, map, switchMap, take } from 'rxjs/operators';
|
||||||
|
|
||||||
function loadCustomTheme() {
|
function loadCustomTheme() {
|
||||||
const cssFileName = getConfig<AppConfig>().THEME;
|
const cssFileName = getConfig<AppConfig>().THEME;
|
||||||
@ -26,9 +26,7 @@ function loadCustomTheme() {
|
|||||||
selector: 'redaction-root',
|
selector: 'redaction-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnDestroy {
|
export class AppComponent {
|
||||||
readonly #subscription = new Subscription();
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
/** ViewContainerRef needs to be injected for the color picker to work */
|
/** ViewContainerRef needs to be injected for the color picker to work */
|
||||||
readonly viewContainerRef: ViewContainerRef,
|
readonly viewContainerRef: ViewContainerRef,
|
||||||
@ -37,20 +35,20 @@ export class AppComponent implements OnDestroy {
|
|||||||
userPreferenceService: UserPreferenceService,
|
userPreferenceService: UserPreferenceService,
|
||||||
renderer: Renderer2,
|
renderer: Renderer2,
|
||||||
private readonly _router: Router,
|
private readonly _router: Router,
|
||||||
route: ActivatedRoute,
|
|
||||||
) {
|
) {
|
||||||
renderer.addClass(inject(DOCUMENT).body, userPreferenceService.getTheme());
|
renderer.addClass(inject(DOCUMENT).body, userPreferenceService.getTheme());
|
||||||
loadCustomTheme();
|
loadCustomTheme();
|
||||||
const sub = route.queryParamMap.subscribe(queryParams => this.#navigate(queryParams));
|
const removeQueryParams = _router.events.pipe(
|
||||||
this.#subscription.add(sub);
|
filter((event): event is NavigationEnd => event instanceof NavigationEnd),
|
||||||
|
map(event => event.urlAfterRedirects),
|
||||||
|
filter(url => url.includes('code=') || url.includes('state=') || url.includes('session_state=')),
|
||||||
|
switchMap(() => this.#removeKeycloakQueryParams()),
|
||||||
|
take(1),
|
||||||
|
);
|
||||||
|
removeQueryParams.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
#removeKeycloakQueryParams() {
|
||||||
this.#subscription.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigate(queryParams: ParamMap) {
|
|
||||||
if (queryParams.has('code') || queryParams.has('state') || queryParams.has('session_state')) {
|
|
||||||
return this._router.navigate([], {
|
return this._router.navigate([], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
state: null,
|
state: null,
|
||||||
@ -60,5 +58,4 @@ export class AppComponent implements OnDestroy {
|
|||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,12 @@
|
|||||||
<ng-container *ngFor="let item of storedTenants | keyvalue; trackBy: trackBy">
|
<ng-container *ngFor="let item of storedTenants | keyvalue; trackBy: trackBy">
|
||||||
<div class="label">{{ item.key }}</div>
|
<div class="label">{{ item.key }}</div>
|
||||||
|
|
||||||
<a (click)="selectTenant(stored.tenant.tenantId)" *ngFor="let stored of item.value" [id]="stored.tenant.tenantId" mat-menu-item>
|
<a
|
||||||
|
(click)="selectTenant(stored.tenant.tenantId, stored.email)"
|
||||||
|
*ngFor="let stored of item.value"
|
||||||
|
[id]="stored.tenant.tenantId"
|
||||||
|
mat-menu-item
|
||||||
|
>
|
||||||
{{ stored.email }}
|
{{ stored.email }}
|
||||||
</a>
|
</a>
|
||||||
<mat-divider class="pb-3 pt-3"></mat-divider>
|
<mat-divider class="pb-3 pt-3"></mat-divider>
|
||||||
|
|||||||
@ -22,9 +22,12 @@ export class TenantsMenuComponent {
|
|||||||
return item.key;
|
return item.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTenant(tenantId?: string) {
|
selectTenant(tenantId?: string, email?: string) {
|
||||||
const tenant = tenantId ? '/' + tenantId : '/';
|
let tenantUrl = tenantId ? '/' + tenantId + '/main' : '/';
|
||||||
window.open(window.location.origin + this.#baseHref + tenant, '_blank');
|
if (email) {
|
||||||
|
tenantUrl += '?username=' + email;
|
||||||
|
}
|
||||||
|
window.open(window.location.origin + this.#baseHref + tenantUrl, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
#getStoredTenants(): Map<string, IStoredTenant[]> {
|
#getStoredTenants(): Map<string, IStoredTenant[]> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user