Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-06-27 12:57:38 +03:00
commit 55b7817ae1
1 changed files with 11 additions and 7 deletions

View File

@ -12,7 +12,7 @@ import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { KeycloakEventType, KeycloakService } from 'keycloak-angular'; import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
import { Observable, Subject, forkJoin, from, of } from 'rxjs'; 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 { ConfigurationService } from '../configuration/configuration.service';
import { PrincipalService } from '../http/principal.service'; import { PrincipalService } from '../http/principal.service';
import { TenantHandlingService } from '../tenant/tenant-handling.service'; import { TenantHandlingService } from '../tenant/tenant-handling.service';
@ -170,13 +170,17 @@ export class AuthService extends BaseService {
public prepareAuthRequest(observable: Observable<string>, tenantCode: string, httpParams?: Object): Observable<boolean> { public prepareAuthRequest(observable: Observable<string>, tenantCode: string, httpParams?: Object): Observable<boolean> {
return observable.pipe( return observable.pipe(
map((x) => this.currentAuthenticationToken(x)), map((x) => this.currentAuthenticationToken(x)),
exhaustMap(() => forkJoin([ concatMap(response => {
this.accessToken ? this.ensureTenant(tenantCode ?? this.selectedTenant() ?? 'default') : of(false), return 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.principalService.me(httpParams) : of(null);
}),
concatMap(response => {
this.currentAccount(response);
return this.accessToken ? this.tenantHandlingService.loadTenantCssColors() : of(null);
}),
map((item) => { map((item) => {
this.currentAccount(item[1]);
this.tenantHandlingService.applyTenantCssColors(item[2]?.cssColors); this.tenantHandlingService.applyTenantCssColors(item[2]?.cssColors);
return true; return true;
}) })