add permissions filter
This commit is contained in:
parent
2f10819460
commit
c744c73845
@ -7,4 +7,5 @@ export class DefaultUserService extends IqserUserService {
|
||||
protected readonly _defaultModelPath = 'user';
|
||||
protected readonly _entityClass = IqserUser;
|
||||
protected readonly _rolesFilter = () => true;
|
||||
protected readonly _permissionsFilter = () => true;
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ export abstract class IqserUserService<
|
||||
> extends EntitiesService<Interface, Class> {
|
||||
readonly currentUser$: Observable<Class | undefined>;
|
||||
protected abstract readonly _defaultModelPath: string;
|
||||
protected abstract readonly _permissionsFilter: (role: string) => boolean;
|
||||
protected abstract readonly _rolesFilter: (role: string) => boolean;
|
||||
protected abstract readonly _entityClass: new (entityInterface: Interface | KeycloakProfile, ...args: unknown[]) => Class;
|
||||
protected readonly _currentUser$ = new BehaviorSubject<Class | undefined>(undefined);
|
||||
@ -84,8 +85,10 @@ export abstract class IqserUserService<
|
||||
return;
|
||||
}
|
||||
|
||||
const roles = this._keycloakService.getUserRoles(true).filter(role => this._rolesFilter(role));
|
||||
this._permissionsService?.load(roles);
|
||||
const all = this._keycloakService.getUserRoles(true);
|
||||
const permissions = all.filter(role => this._permissionsFilter(role));
|
||||
const roles = all.filter(role => this._rolesFilter(role));
|
||||
this._permissionsService?.load(permissions);
|
||||
this._rolesService?.load(roles);
|
||||
const user = new this._entityClass(profile, roles, profile.id);
|
||||
this.replace(user);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user