mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
update typing
This commit is contained in:
@@ -34,7 +34,7 @@ import { PasswordInputResult } from "../input-password/password-input-result";
|
||||
export class ChangePasswordComponent implements OnInit {
|
||||
@Input() inputPasswordFlow: InputPasswordFlow = InputPasswordFlow.ChangePassword;
|
||||
|
||||
activeAccount?: Account;
|
||||
activeAccount: Account | null = null;
|
||||
email?: string;
|
||||
userId?: UserId;
|
||||
masterPasswordPolicyOptions?: MasterPasswordPolicyOptions;
|
||||
@@ -62,6 +62,10 @@ export class ChangePasswordComponent implements OnInit {
|
||||
this.userId = this.activeAccount?.id;
|
||||
this.email = this.activeAccount?.email;
|
||||
|
||||
if (this.userId == null) {
|
||||
throw new Error("UserId cannot be null");
|
||||
}
|
||||
|
||||
this.masterPasswordPolicyOptions = await firstValueFrom(
|
||||
this.policyService.masterPasswordPolicyOptions$(this.userId),
|
||||
);
|
||||
|
||||
@@ -34,12 +34,7 @@ import {
|
||||
ToastService,
|
||||
Translation,
|
||||
} from "@bitwarden/components";
|
||||
import {
|
||||
DEFAULT_KDF_CONFIG,
|
||||
KdfConfig,
|
||||
KdfConfigService,
|
||||
KeyService,
|
||||
} from "@bitwarden/key-management";
|
||||
import { KdfConfig, KdfConfigService, KeyService } from "@bitwarden/key-management";
|
||||
|
||||
// FIXME: remove `src` and fix import
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
@@ -108,7 +103,7 @@ export class InputPasswordComponent implements OnInit {
|
||||
protected secondaryButtonTextStr: string = "";
|
||||
|
||||
protected InputPasswordFlow = InputPasswordFlow;
|
||||
private kdfConfig: KdfConfig = DEFAULT_KDF_CONFIG;
|
||||
private kdfConfig: KdfConfig | null = null;
|
||||
private minHintLength = 0;
|
||||
protected maxHintLength = 50;
|
||||
protected minPasswordLength = Utils.minimumPasswordLength;
|
||||
@@ -240,6 +235,7 @@ export class InputPasswordComponent implements OnInit {
|
||||
const currentPasswordIsCorrect = await this.verifyCurrentPassword(
|
||||
currentPassword,
|
||||
this.userId,
|
||||
this.kdfConfig,
|
||||
);
|
||||
if (!currentPasswordIsCorrect) {
|
||||
return;
|
||||
@@ -326,11 +322,15 @@ export class InputPasswordComponent implements OnInit {
|
||||
/**
|
||||
* Returns true if the current password is correct, false otherwise
|
||||
*/
|
||||
private async verifyCurrentPassword(currentPassword: string, userId: UserId): Promise<boolean> {
|
||||
private async verifyCurrentPassword(
|
||||
currentPassword: string,
|
||||
userId: UserId,
|
||||
kdfConfig: KdfConfig,
|
||||
): Promise<boolean> {
|
||||
const currentMasterKey = await this.keyService.makeMasterKey(
|
||||
currentPassword,
|
||||
this.email.trim().toLowerCase(),
|
||||
this.kdfConfig,
|
||||
kdfConfig,
|
||||
);
|
||||
|
||||
const decryptedUserKey = await this.masterPasswordService.decryptUserKeyWithMasterKey(
|
||||
|
||||
Reference in New Issue
Block a user