diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts
index f6042ae1de..a0080475dc 100644
--- a/src/app/accounts/register.component.ts
+++ b/src/app/accounts/register.component.ts
@@ -10,10 +10,12 @@ import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
+import { PolicyService } from 'jslib/abstractions/policy.service';
import { StateService } from 'jslib/abstractions/state.service';
import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/components/register.component';
+import { MasterPasswordPolicyOptions } from 'jslib/models/domain/masterPasswordPolicyOptions';
import { Policy } from 'jslib/models/domain/policy';
import { PolicyData } from 'jslib/models/data/policyData';
@@ -27,12 +29,13 @@ export class RegisterComponent extends BaseRegisterComponent {
showTerms = true;
private policies: Policy[];
+ enforcedPolicyOptions: MasterPasswordPolicyOptions;
constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, private route: ActivatedRoute,
stateService: StateService, platformUtilsService: PlatformUtilsService,
- passwordGenerationService: PasswordGenerationService) {
+ passwordGenerationService: PasswordGenerationService, private policyService: PolicyService) {
super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService,
passwordGenerationService);
this.showTerms = !platformUtilsService.isSelfHost();
@@ -65,5 +68,21 @@ export class RegisterComponent extends BaseRegisterComponent {
}
} catch { }
}
+
+ if (this.policies != null) {
+ this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions(this.policies);
+ }
+ }
+
+ async submit() {
+ if (this.enforcedPolicyOptions != null &&
+ !this.policyService.evaluateMasterPassword(this.masterPasswordScore, this.masterPassword,
+ this.enforcedPolicyOptions)) {
+ this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
+ this.i18nService.t('masterPasswordPolicyRequirementsNotMet'));
+ return;
+ }
+
+ await super.submit();
}
}
diff --git a/src/app/organizations/manage/policy-edit.component.html b/src/app/organizations/manage/policy-edit.component.html
index d3dca0de37..23c3277756 100644
--- a/src/app/organizations/manage/policy-edit.component.html
+++ b/src/app/organizations/manage/policy-edit.component.html
@@ -33,7 +33,7 @@
-