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
1 changed files with 11 additions and 2 deletions

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;
};
}
}