1
0
mirror of https://github.com/bitwarden/web synced 2025-12-22 03:03:26 +00:00

Add copy descriptions and warnings to policies (#470)

This commit is contained in:
Kyle Spearrin
2020-02-27 13:07:33 -05:00
committed by GitHub
parent a27eddae56
commit 1d94185078
6 changed files with 49 additions and 11 deletions

View File

@@ -9,10 +9,12 @@ import {
import { ApiService } from 'jslib/abstractions/api.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PolicyService } from 'jslib/abstractions/policy.service';
import { UserService } from 'jslib/abstractions/user.service';
import { TwoFactorProviders } from 'jslib/services/auth.service';
import { PolicyType } from 'jslib/enums/policyType';
import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType';
import { ModalComponent } from '../modal.component';
@@ -39,12 +41,14 @@ export class TwoFactorSetupComponent implements OnInit {
organizationId: string;
providers: any[] = [];
canAccessPremium: boolean;
showPolicyWarning = false;
loading = true;
private modal: ModalComponent = null;
constructor(protected apiService: ApiService, protected userService: UserService,
protected componentFactoryResolver: ComponentFactoryResolver, protected messagingService: MessagingService) { }
protected componentFactoryResolver: ComponentFactoryResolver, protected messagingService: MessagingService,
protected policyService: PolicyService) { }
async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium();
@@ -83,6 +87,7 @@ export class TwoFactorSetupComponent implements OnInit {
}
});
});
this.evaluatePolicies();
this.loading = false;
}
@@ -166,5 +171,15 @@ export class TwoFactorSetupComponent implements OnInit {
p.enabled = enabled;
}
});
this.evaluatePolicies();
}
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);
} else {
this.showPolicyWarning = false;
}
}
}