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:
parent
cc359e905b
commit
bc73452400
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user