diff --git a/libs/auth/src/angular/input-password/input-password.component.ts b/libs/auth/src/angular/input-password/input-password.component.ts index feb72846b77..4bc8c098e23 100644 --- a/libs/auth/src/angular/input-password/input-password.component.ts +++ b/libs/auth/src/angular/input-password/input-password.component.ts @@ -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