mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +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() {
|
get isOwner() {
|
||||||
return this.type === OrganizationUserType.Owner;
|
return this.type === OrganizationUserType.Owner || this.isProviderUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canAccessBusinessPortal() {
|
get canAccessBusinessPortal() {
|
||||||
|
@ -172,21 +172,18 @@ export class PolicyService implements PolicyServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async policyAppliesToUser(policyType: PolicyType, policyFilter?: (policy: Policy) => boolean) {
|
async policyAppliesToUser(policyType: PolicyType, policyFilter?: (policy: Policy) => boolean) {
|
||||||
if (policyFilter == null) {
|
|
||||||
policyFilter = (policy: Policy) => true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const policies = await this.getAll(policyType);
|
const policies = await this.getAll(policyType);
|
||||||
const organizations = await this.userService.getAllOrganizations();
|
const organizations = await this.userService.getAllOrganizations();
|
||||||
|
let filteredPolicies;
|
||||||
|
|
||||||
const filteredPolicies = policies
|
if (policyFilter != null) {
|
||||||
.filter(p =>
|
filteredPolicies = policies.filter(p => p.enabled && policyFilter(p));
|
||||||
p.enabled &&
|
}
|
||||||
p.type === policyType &&
|
else {
|
||||||
policyFilter(p))
|
filteredPolicies = policies.filter(p => p.enabled);
|
||||||
.map(p => p.organizationId);
|
}
|
||||||
|
|
||||||
const policySet = new Set(filteredPolicies);
|
const policySet = new Set(filteredPolicies.map(p => p.organizationId));
|
||||||
|
|
||||||
return organizations.some(o =>
|
return organizations.some(o =>
|
||||||
o.enabled &&
|
o.enabled &&
|
||||||
|
Loading…
Reference in New Issue
Block a user