From 37ae16341facc38f515e7f0061ee06ad645f0b38 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 27 Jun 2024 12:51:47 +0300 Subject: [PATCH] authe service login flow change --- .../src/app/core/services/auth/auth.service.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index 877f079d2..3c222bd8b 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -12,7 +12,7 @@ import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; import { KeycloakEventType, KeycloakService } from 'keycloak-angular'; import { Observable, Subject, forkJoin, from, of } from 'rxjs'; -import { exhaustMap, map, takeUntil } from 'rxjs/operators'; +import { concatMap, exhaustMap, map, takeUntil } from 'rxjs/operators'; import { ConfigurationService } from '../configuration/configuration.service'; import { PrincipalService } from '../http/principal.service'; import { TenantHandlingService } from '../tenant/tenant-handling.service'; @@ -170,13 +170,17 @@ export class AuthService extends BaseService { public prepareAuthRequest(observable: Observable, tenantCode: string, httpParams?: Object): Observable { return observable.pipe( map((x) => this.currentAuthenticationToken(x)), - exhaustMap(() => forkJoin([ - this.accessToken ? this.ensureTenant(tenantCode ?? this.selectedTenant() ?? 'default') : of(false), - this.accessToken ? this.principalService.me(httpParams) : of(null), - this.accessToken ? this.tenantHandlingService.loadTenantCssColors() : of(null), - ])), + concatMap(response => { + return this.accessToken ? this.ensureTenant(tenantCode ?? this.selectedTenant() ?? 'default') : of(false); + }), + concatMap(response => { + return this.accessToken ? this.principalService.me(httpParams) : of(null); + }), + concatMap(response => { + this.currentAccount(response); + return this.accessToken ? this.tenantHandlingService.loadTenantCssColors() : of(null); + }), map((item) => { - this.currentAccount(item[1]); this.tenantHandlingService.applyTenantCssColors(item[2]?.cssColors); return true; })