mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
[EC-739 / EC-740] Add null check to policyFilter on PolicyService (#4039)
* [EC-739 / EC-740] Add null check to policyFilter on PolicyService * [EC-739 / EC-740] Add unit tests for policy filter
This commit is contained in:
@@ -124,10 +124,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
);
|
||||
}
|
||||
|
||||
policyAppliesToActiveUser$(
|
||||
policyType: PolicyType,
|
||||
policyFilter: (policy: Policy) => boolean = (p) => true
|
||||
) {
|
||||
policyAppliesToActiveUser$(policyType: PolicyType, policyFilter?: (policy: Policy) => boolean) {
|
||||
return this.policies$.pipe(
|
||||
concatMap(async (policies) => {
|
||||
const userId = await this.stateService.getUserId();
|
||||
@@ -257,12 +254,12 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
private async checkPoliciesThatApplyToUser(
|
||||
policies: Policy[],
|
||||
policyType: PolicyType,
|
||||
policyFilter: (policy: Policy) => boolean = (p) => true,
|
||||
policyFilter?: (policy: Policy) => boolean,
|
||||
userId?: string
|
||||
) {
|
||||
const organizations = await this.organizationService.getAll(userId);
|
||||
const filteredPolicies = policies.filter(
|
||||
(p) => p.type === policyType && p.enabled && policyFilter(p)
|
||||
(p) => p.type === policyType && p.enabled && (policyFilter == null || policyFilter(p))
|
||||
);
|
||||
const policySet = new Set(filteredPolicies.map((p) => p.organizationId));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user