1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Fixed self host defect (#3094)

This commit is contained in:
Gbubemi Smith 2022-07-13 15:14:03 +01:00 committed by GitHub
parent 0a06ae0ec5
commit 6a26223f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import { Directive, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { AbstractControl, FormBuilder, ValidatorFn, Validators } from "@angular/forms";
import { Router } from "@angular/router";
import { InputsFieldMatch } from "@bitwarden/angular/validators/inputsFieldMatch.validator";
@ -50,7 +50,7 @@ export class RegisterComponent extends CaptchaProtectedComponent implements OnIn
),
],
],
acceptPolicies: [false, [Validators.requiredTrue]],
acceptPolicies: [false, [this.acceptPoliciesValidation()]],
},
{
validator: InputsFieldMatch.validateFormInputsMatch(
@ -275,4 +275,13 @@ export class RegisterComponent extends CaptchaProtectedComponent implements OnIn
const name = error.errorName.charAt(0).toUpperCase() + error.errorName.slice(1);
return `${error.controlName}${name}`;
}
//validation would be ignored on selfhosted
private acceptPoliciesValidation(): ValidatorFn {
return (control: AbstractControl) => {
const ctrlValue = control.value;
return !ctrlValue && this.showTerms ? { required: true } : null;
};
}
}