1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02: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:
Thomas Rittson 2021-09-09 07:34:27 +10:00 committed by GitHub
parent bbe8d3df48
commit 5f64d95652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -89,7 +89,7 @@ export class Organization {
}
get isOwner() {
return this.type === OrganizationUserType.Owner;
return this.type === OrganizationUserType.Owner || this.isProviderUser;
}
get canAccessBusinessPortal() {

View File

@ -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 &&