mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Fixes and cleanup for policyAppliesToUser (#476)
* Fix canManagePolicies logic to include providers * Move new logic to isOwner (same as server) * Refactor policyAppliesToUser * Use const instead of var * Fix linting
This commit is contained in:
parent
bbe8d3df48
commit
5f64d95652
@ -89,7 +89,7 @@ export class Organization {
|
||||
}
|
||||
|
||||
get isOwner() {
|
||||
return this.type === OrganizationUserType.Owner;
|
||||
return this.type === OrganizationUserType.Owner || this.isProviderUser;
|
||||
}
|
||||
|
||||
get canAccessBusinessPortal() {
|
||||
|
@ -172,21 +172,18 @@ export class PolicyService implements PolicyServiceAbstraction {
|
||||
}
|
||||
|
||||
async policyAppliesToUser(policyType: PolicyType, policyFilter?: (policy: Policy) => boolean) {
|
||||
if (policyFilter == null) {
|
||||
policyFilter = (policy: Policy) => true;
|
||||
}
|
||||
|
||||
const policies = await this.getAll(policyType);
|
||||
const organizations = await this.userService.getAllOrganizations();
|
||||
let filteredPolicies;
|
||||
|
||||
const filteredPolicies = policies
|
||||
.filter(p =>
|
||||
p.enabled &&
|
||||
p.type === policyType &&
|
||||
policyFilter(p))
|
||||
.map(p => p.organizationId);
|
||||
if (policyFilter != null) {
|
||||
filteredPolicies = policies.filter(p => p.enabled && policyFilter(p));
|
||||
}
|
||||
else {
|
||||
filteredPolicies = policies.filter(p => p.enabled);
|
||||
}
|
||||
|
||||
const policySet = new Set(filteredPolicies);
|
||||
const policySet = new Set(filteredPolicies.map(p => p.organizationId));
|
||||
|
||||
return organizations.some(o =>
|
||||
o.enabled &&
|
||||
|
Loading…
Reference in New Issue
Block a user