From 350ad890decc28cdd6a183a1af3e66769d802864 Mon Sep 17 00:00:00 2001 From: Timshel Date: Wed, 8 May 2024 18:24:18 +0200 Subject: [PATCH] Check MasterPassword in web app during change (#8293) --- .../auth/settings/change-password.component.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/auth/settings/change-password.component.ts b/apps/web/src/app/auth/settings/change-password.component.ts index 454d96f2bd..fb428def9f 100644 --- a/apps/web/src/app/auth/settings/change-password.component.ts +++ b/apps/web/src/app/auth/settings/change-password.component.ts @@ -165,7 +165,22 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent { newMasterKey: MasterKey, newUserKey: [UserKey, EncString], ) { - const masterKey = await this.cryptoService.getOrDeriveMasterKey(this.currentMasterPassword); + const masterKey = await this.cryptoService.makeMasterKey( + this.currentMasterPassword, + await this.stateService.getEmail(), + await this.kdfConfigService.getKdfConfig(), + ); + + const userKey = await this.cryptoService.decryptUserKeyWithMasterKey(masterKey); + if (userKey == null) { + this.platformUtilsService.showToast( + "error", + null, + this.i18nService.t("invalidMasterPassword"), + ); + return; + } + const request = new PasswordRequest(); request.masterPasswordHash = await this.cryptoService.hashMasterKey( this.currentMasterPassword,