1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-19 02:44:01 +00:00

[PM-18721] extract some submit logic to handleChangePasswordDelegationFlow()

This commit is contained in:
rr-bw
2025-05-07 16:11:03 -07:00
parent cd4ee56238
commit 1a209f2f8c

View File

@@ -267,24 +267,13 @@ export class InputPasswordComponent implements OnInit {
return;
}
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 ?? true;
if (this.flow === InputPasswordFlow.ChangePasswordDelegation) {
const newPassword = this.formGroup.controls.newPassword.value;
const newPasswordVerified = await this.verifyNewPassword(
newPassword,
this.passwordStrengthScore,
false,
);
if (!newPasswordVerified) {
return;
}
const passwordInputResult: PasswordInputResult = {
newPassword,
};
this.onPasswordFormSubmit.emit(passwordInputResult);
await this.handleChangePasswordDelegationFlow(newPassword);
return;
}
@@ -292,11 +281,6 @@ export class InputPasswordComponent implements OnInit {
throw new Error("Email is required to create master key.");
}
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 ?? true;
// 1. Determine kdfConfig
if (this.flow === InputPasswordFlow.SetInitialPasswordAccountRegistration) {
this.kdfConfig = DEFAULT_KDF_CONFIG;
@@ -445,6 +429,23 @@ export class InputPasswordComponent implements OnInit {
}
}
private async handleChangePasswordDelegationFlow(newPassword: string) {
const newPasswordVerified = await this.verifyNewPassword(
newPassword,
this.passwordStrengthScore,
false,
);
if (!newPasswordVerified) {
return;
}
const passwordInputResult: PasswordInputResult = {
newPassword,
};
this.onPasswordFormSubmit.emit(passwordInputResult);
}
/**
* Returns `true` if the current password is correct (it can be used to successfully decrypt
* the masterKeyEncrypedUserKey), `false` otherwise