RED-8012 - fixed blank page when reloading.
This commit is contained in:
parent
986d552e49
commit
68dbdfb8e7
@ -1,11 +1,10 @@
|
||||
import { IqserAppConfig } from '../utils';
|
||||
import { IqserAppConfig, UI_ROOT } from '../utils';
|
||||
import { KeycloakOptions, KeycloakService } from 'keycloak-angular';
|
||||
import { KeycloakStatusService } from './services/keycloak-status.service';
|
||||
import { inject } from '@angular/core';
|
||||
import { getConfig } from '../services';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { Router } from '@angular/router';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
|
||||
export function getKeycloakOptions(baseUrl: string, config: IqserAppConfig, tenant: string): KeycloakOptions {
|
||||
let oauthUrl = config.OAUTH_URL;
|
||||
@ -49,10 +48,10 @@ export async function keycloakInitializer(tenant: string) {
|
||||
const router = inject(Router);
|
||||
const keycloakService = inject(KeycloakService);
|
||||
const keycloakStatusService = inject(KeycloakStatusService);
|
||||
const baseHref = inject(APP_BASE_HREF);
|
||||
const uiRoot = inject(UI_ROOT);
|
||||
const config = getConfig();
|
||||
|
||||
const keycloakOptions = getKeycloakOptions(baseHref, config, tenant);
|
||||
const keycloakOptions = getKeycloakOptions(uiRoot, config, tenant);
|
||||
try {
|
||||
await keycloakService.init(keycloakOptions);
|
||||
} catch (error) {
|
||||
|
||||
@ -8,7 +8,7 @@ import { getConfig } from '../../services';
|
||||
import { getKeycloakOptions } from '../keycloak-initializer';
|
||||
import { IStoredTenantId, TenantsService } from '../services';
|
||||
import { KeycloakStatusService } from '../services/keycloak-status.service';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { UI_ROOT } from '../../utils';
|
||||
|
||||
@Component({
|
||||
templateUrl: './tenant-select.component.html',
|
||||
@ -17,7 +17,6 @@ import { APP_BASE_HREF } from '@angular/common';
|
||||
})
|
||||
export class TenantSelectComponent {
|
||||
@Input() isLoggedOut = false;
|
||||
protected readonly baseHref = inject(APP_BASE_HREF);
|
||||
protected readonly logger = inject(NGXLogger);
|
||||
protected readonly tenantsService = inject(TenantsService);
|
||||
protected storedTenants: IStoredTenantId[] = [];
|
||||
@ -30,6 +29,7 @@ export class TenantSelectComponent {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
tenantId: ['', Validators.required],
|
||||
});
|
||||
readonly #uiRoot = inject(UI_ROOT);
|
||||
|
||||
constructor() {
|
||||
this.#loadStoredTenants();
|
||||
@ -48,7 +48,7 @@ export class TenantSelectComponent {
|
||||
async select(tenantId: string) {
|
||||
try {
|
||||
this.logger.info('[KEYCLOAK] Initializing keycloak for tenant', tenantId);
|
||||
await this.keycloakService.init(getKeycloakOptions(this.baseHref, this.config, tenantId));
|
||||
await this.keycloakService.init(getKeycloakOptions(this.#uiRoot, this.config, tenantId));
|
||||
} catch (e) {
|
||||
this.logger.info('[KEYCLOAK] Init failed. Logout');
|
||||
return this.keycloakService.logout();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user