update user service
This commit is contained in:
parent
0002b481bf
commit
3658c65672
@ -38,6 +38,10 @@ export type IqserRoute = Route & {
|
||||
data?: {
|
||||
permissions?: IqserPermissionsRouterData;
|
||||
};
|
||||
|
||||
children?: List<IqserRoute>;
|
||||
};
|
||||
|
||||
export type IqserRoutes = IqserRoute[];
|
||||
|
||||
export const DEFAULT_REDIRECT_KEY = 'default';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { inject, Injectable, InjectFlags } from '@angular/core';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
@ -34,8 +34,8 @@ export abstract class IqserUserService<
|
||||
protected readonly _baseHref = inject(BASE_HREF);
|
||||
protected readonly _keycloakService = inject(KeycloakService);
|
||||
protected readonly _cacheApiService = inject(CacheApiService);
|
||||
protected readonly _permissionsService = inject(IqserPermissionsService, InjectFlags.Optional);
|
||||
protected readonly _rolesService = inject(IqserRolesService, InjectFlags.Optional);
|
||||
protected readonly _permissionsService = inject(IqserPermissionsService, { optional: true });
|
||||
protected readonly _rolesService = inject(IqserRolesService, { optional: true });
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -86,7 +86,7 @@ export abstract class IqserUserService<
|
||||
const decoded: IToken = jwt_decode(token);
|
||||
const userId = decoded.sub;
|
||||
const realm = this._keycloakService.getKeycloakInstance().realm || '';
|
||||
this._permissionsService?.load(decoded.resource_access[realm].roles);
|
||||
this._permissionsService?.load(decoded.resource_access[realm]?.roles ?? []);
|
||||
|
||||
const roles = this._keycloakService.getUserRoles(true).filter(role => this._rolesFilter(role));
|
||||
this._rolesService?.load(roles);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user