1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

Move policy checks within policyService (#1149)

* Refactor: use new policyService methods

* Update jslib
This commit is contained in:
Thomas Rittson 2021-09-02 07:51:04 +10:00 committed by GitHub
parent cc359e905b
commit bc73452400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 15 deletions

View File

@ -136,8 +136,9 @@ export class PeopleComponent extends BasePeopleComponent<OrganizationUserUserDet
}
async load() {
const policies = await this.policyService.getAll(PolicyType.ResetPassword);
this.orgResetPasswordPolicyEnabled = policies.some(p => p.organizationId === this.organizationId && p.enabled);
const resetPasswordPolicy = await this.policyService.getPolicyForOrganization(PolicyType.ResetPassword,
this.organizationId);
this.orgResetPasswordPolicyEnabled = resetPasswordPolicy?.enabled;
super.load();
}

View File

@ -268,17 +268,7 @@ export class OrganizationPlansComponent implements OnInit {
}
private async userHasBlockingSingleOrgPolicy() {
const policies = await this.policyService.getAll(PolicyType.SingleOrg);
const orgs = await this.userService.getAllOrganizations();
const orgsWithSingleOrgPolicy = policies
.filter(p => p.enabled && p.type === PolicyType.SingleOrg)
.map(p => p.organizationId);
return orgs.some(org => org.type !== OrganizationUserType.Owner &&
org.type !== OrganizationUserType.Admin &&
org.status !== OrganizationUserStatusType.Invited &&
orgsWithSingleOrgPolicy.includes(org.id));
return this.policyService.policyAppliesToUser(PolicyType.SingleOrg);
}
private async updateOrganization(orgId: string) {

View File

@ -168,8 +168,7 @@ export class TwoFactorSetupComponent implements OnInit {
private async evaluatePolicies() {
if (this.organizationId == null && this.providers.filter(p => p.enabled).length === 1) {
const policies = await this.policyService.getAll(PolicyType.TwoFactorAuthentication);
this.showPolicyWarning = policies != null && policies.some(p => p.enabled);
this.showPolicyWarning = await this.policyService.policyAppliesToUser(PolicyType.TwoFactorAuthentication);
} else {
this.showPolicyWarning = false;
}