Skip to content

Commit

Permalink
Permission service should filter granted policies from list of policy
Browse files Browse the repository at this point in the history
resolve #7572
  • Loading branch information
muhammedaltug committed Feb 2, 2021
1 parent 0be42b5 commit 183b4a7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions npm/ng-packs/packages/core/src/lib/services/permission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export class PermissionService {
return this.isPolicyGranted(key, policies);
}

filterGrantedPolicies(policyKeys: Array<string>) {
const policies = this.getSnapshot();
return policyKeys.filter(key => this.isPolicyGranted(key, policies));
}

filterGrantedPolicies$(policyKeys: Array<string>) {
return this.getStream().pipe(
map(policies => policyKeys.filter(key => this.isPolicyGranted(key, policies))),
);
}

protected isPolicyGranted(key: string, grantedPolicies: Record<string, boolean>) {
if (!key) return true;

Expand Down

0 comments on commit 183b4a7

Please sign in to comment.