1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-28 10:33:31 +00:00

[PM-18721] add ChangePasswordDelegation flow to InputPasswordComponent

This commit is contained in:
rr-bw
2025-05-04 20:20:47 -07:00
parent c20b99730b
commit 1e22cb51a3
5 changed files with 68 additions and 32 deletions

View File

@@ -56,6 +56,10 @@ export enum InputPasswordFlow {
* Form elements displayed:
* - [Input] New password
* - [Input] New password confirm
*/
ChangePasswordDelegation,
/**
* All form elements above, plus:
* - [Input] New password hint
* - [Checkbox] Check for breaches
*/
@@ -74,9 +78,9 @@ export enum InputPasswordFlow {
interface InputPasswordForm {
newPassword: FormControl<string>;
newPasswordConfirm: FormControl<string>;
newPasswordHint: FormControl<string>;
checkForBreaches: FormControl<boolean>;
newPasswordHint?: FormControl<string>;
checkForBreaches?: FormControl<boolean>;
currentPassword?: FormControl<string>;
rotateUserKey?: FormControl<boolean>;
}
@@ -147,12 +151,6 @@ export class InputPasswordComponent implements OnInit {
"newPasswordConfirm",
this.i18nService.t("masterPassDoesntMatch"),
),
compareInputs(
ValidationGoal.InputsShouldNotMatch,
"newPassword",
"newPasswordHint",
this.i18nService.t("hintEqualsPassword"),
),
],
},
);
@@ -188,6 +186,26 @@ export class InputPasswordComponent implements OnInit {
}
private addFormFieldsIfNecessary() {
if (this.flow !== InputPasswordFlow.ChangePasswordDelegation) {
this.formGroup.addControl(
"newPasswordHint",
new FormControl("", [
Validators.minLength(this.minHintLength),
Validators.maxLength(this.maxHintLength),
]) as FormControl<string>,
);
this.formGroup.addControl("checkForBreaches", new FormControl(true) as FormControl<boolean>);
this.formGroup.addValidators([
compareInputs(
ValidationGoal.InputsShouldNotMatch,
"newPassword",
"newPasswordHint",
this.i18nService.t("hintEqualsPassword"),
),
]);
}
if (
this.flow === InputPasswordFlow.ChangePassword ||
this.flow === InputPasswordFlow.ChangePasswordWithOptionalUserKeyRotation
@@ -244,8 +262,8 @@ export class InputPasswordComponent implements OnInit {
const currentPassword = this.formGroup.controls.currentPassword?.value ?? "";
const newPassword = this.formGroup.controls.newPassword.value;
const newPasswordHint = this.formGroup.controls.newPasswordHint.value;
const checkForBreaches = this.formGroup.controls.checkForBreaches.value;
const newPasswordHint = this.formGroup.controls.newPasswordHint?.value ?? "";
const checkForBreaches = this.formGroup.controls.checkForBreaches?.value ?? true;
// 1. Determine kdfConfig
if (this.flow === InputPasswordFlow.AccountRegistration) {