diff --git a/libs/auth/src/angular/change-password/change-password.component.ts b/libs/auth/src/angular/change-password/change-password.component.ts index 86b7c884e92..fc4fbd21bcb 100644 --- a/libs/auth/src/angular/change-password/change-password.component.ts +++ b/libs/auth/src/angular/change-password/change-password.component.ts @@ -72,8 +72,11 @@ export class ChangePasswordComponent implements OnInit { throw new Error("activeAccount not found"); } - if (passwordInputResult.currentPassword == null) { - throw new Error("currentPassword not found"); + if ( + passwordInputResult.currentPassword == null || + passwordInputResult.newPasswordHint == null + ) { + throw new Error("currentPassword or newPasswordHint not found"); } await this.syncService.fullSync(true); diff --git a/libs/auth/src/angular/change-password/default-change-password.service.ts b/libs/auth/src/angular/change-password/default-change-password.service.ts index 315f979aad9..4c5f3d10d74 100644 --- a/libs/auth/src/angular/change-password/default-change-password.service.ts +++ b/libs/auth/src/angular/change-password/default-change-password.service.ts @@ -26,8 +26,14 @@ export class DefaultChangePasswordService implements ChangePasswordService { if (!userId) { throw new Error("userId not found"); } - if (!passwordInputResult.currentMasterKey || !passwordInputResult.currentServerMasterKeyHash) { - throw new Error("currentMasterKey or currentServerMasterKeyHash not found"); + if ( + !passwordInputResult.currentMasterKey || + !passwordInputResult.currentServerMasterKeyHash || + !passwordInputResult.newMasterKey || + !passwordInputResult.newServerMasterKeyHash || + passwordInputResult.newPasswordHint == null + ) { + throw new Error("invalid PasswordInputResult credentials, could not change password"); } const decryptedUserKey = await this.masterPasswordService.decryptUserKeyWithMasterKey( 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 1896c3885b1..fccb5dfd6d5 100644 --- a/libs/auth/src/angular/input-password/input-password.component.ts +++ b/libs/auth/src/angular/input-password/input-password.component.ts @@ -450,16 +450,19 @@ export class InputPasswordComponent implements OnInit { currentPassword: string, kdfConfig: KdfConfig, ): Promise { + if (!this.email) { + throw new Error("Email is required to verify current password."); + } + if (!this.userId) { + throw new Error("userId is required to verify current password."); + } + const currentMasterKey = await this.keyService.makeMasterKey( currentPassword, this.email, kdfConfig, ); - if (!this.userId) { - throw new Error("userId not passed down"); - } - const decryptedUserKey = await this.masterPasswordService.decryptUserKeyWithMasterKey( currentMasterKey, this.userId,