mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 05:00:10 +00:00
update typing
This commit is contained in:
@@ -38,7 +38,7 @@ export class ChangePasswordComponent implements OnInit {
|
||||
email?: string;
|
||||
masterPasswordPolicyOptions?: MasterPasswordPolicyOptions;
|
||||
userkeyRotationV2 = false;
|
||||
formPromise: Promise<any>;
|
||||
formPromise?: Promise<any>;
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
@@ -77,11 +77,23 @@ export class ChangePasswordComponent implements OnInit {
|
||||
}
|
||||
|
||||
async submitNew(passwordInputResult: PasswordInputResult) {
|
||||
if (
|
||||
passwordInputResult.currentPassword == null ||
|
||||
passwordInputResult.currentMasterKey == null ||
|
||||
passwordInputResult.currentServerMasterKeyHash == null
|
||||
) {
|
||||
throw new Error("Invalid current password credentials");
|
||||
}
|
||||
|
||||
try {
|
||||
if (passwordInputResult.rotateUserKey) {
|
||||
await this.syncService.fullSync(true);
|
||||
const user = await firstValueFrom(this.accountService.activeAccount$);
|
||||
|
||||
if (user == null) {
|
||||
throw new Error("User not found");
|
||||
}
|
||||
|
||||
await this.changePasswordService.rotateUserKeyMasterPasswordAndEncryptedData(
|
||||
passwordInputResult.currentPassword,
|
||||
passwordInputResult.newPassword,
|
||||
@@ -105,23 +117,27 @@ export class ChangePasswordComponent implements OnInit {
|
||||
|
||||
this.messagingService.send("logout");
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
this.toastService.showToast({
|
||||
variant: "error",
|
||||
title: this.i18nService.t("errorOccurred"),
|
||||
message: e.message,
|
||||
title: "",
|
||||
message: this.i18nService.t("errorOccurred"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async submitOld(passwordInputResult: PasswordInputResult) {
|
||||
if (passwordInputResult.currentServerMasterKeyHash == null) {
|
||||
throw new Error("Invalid current password credentials");
|
||||
}
|
||||
|
||||
if (passwordInputResult.rotateUserKey) {
|
||||
await this.syncService.fullSync(true);
|
||||
}
|
||||
|
||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||
|
||||
let newMasterKeyEncryptedUserKey: [UserKey, EncString] = null;
|
||||
let newMasterKeyEncryptedUserKey: [UserKey, EncString] | null = null;
|
||||
|
||||
const userKey = await this.keyService.getUserKey();
|
||||
if (userKey == null) {
|
||||
@@ -138,7 +154,7 @@ export class ChangePasswordComponent implements OnInit {
|
||||
request.masterPasswordHash = passwordInputResult.currentServerMasterKeyHash;
|
||||
request.masterPasswordHint = passwordInputResult.newPasswordHint;
|
||||
request.newMasterPasswordHash = passwordInputResult.newServerMasterKeyHash;
|
||||
request.key = newMasterKeyEncryptedUserKey[1].encryptedString;
|
||||
request.key = newMasterKeyEncryptedUserKey[1].encryptedString as string;
|
||||
|
||||
try {
|
||||
if (passwordInputResult.rotateUserKey) {
|
||||
@@ -169,7 +185,7 @@ export class ChangePasswordComponent implements OnInit {
|
||||
} catch {
|
||||
this.toastService.showToast({
|
||||
variant: "error",
|
||||
title: null,
|
||||
title: "",
|
||||
message: this.i18nService.t("errorOccurred"),
|
||||
});
|
||||
}
|
||||
@@ -177,6 +193,11 @@ export class ChangePasswordComponent implements OnInit {
|
||||
|
||||
private async updateKey(newPassword: string) {
|
||||
const user = await firstValueFrom(this.accountService.activeAccount$);
|
||||
|
||||
if (user == null) {
|
||||
throw new Error("User not found");
|
||||
}
|
||||
|
||||
await this.changePasswordService.rotateUserKeyAndEncryptedDataLegacy(newPassword, user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ export class InputPasswordComponent implements OnInit {
|
||||
protected secondaryButtonTextStr: string = "";
|
||||
|
||||
protected InputPasswordFlow = InputPasswordFlow;
|
||||
private kdfConfig?: KdfConfig;
|
||||
private kdfConfig: KdfConfig = DEFAULT_KDF_CONFIG;
|
||||
private minHintLength = 0;
|
||||
protected maxHintLength = 50;
|
||||
protected minPasswordLength = Utils.minimumPasswordLength;
|
||||
@@ -224,8 +224,10 @@ export class InputPasswordComponent implements OnInit {
|
||||
|
||||
this.kdfConfig = (await this.kdfConfigService.getKdfConfig()) || DEFAULT_KDF_CONFIG;
|
||||
|
||||
const currentPassword = this.formGroup.get("currentPassword")?.value;
|
||||
const { newPassword, newPasswordHint, checkForBreaches } = this.formGroup.value;
|
||||
const currentPassword = this.formGroup.get("currentPassword")?.value || "";
|
||||
const newPassword = this.formGroup.controls.newPassword.value;
|
||||
const newPasswordHint = this.formGroup.controls.newPasswordHint.value;
|
||||
const checkForBreaches = this.formGroup.controls.checkForBreaches.value;
|
||||
|
||||
// 1. Verify current password is correct (if necessary)
|
||||
if (
|
||||
@@ -336,7 +338,7 @@ export class InputPasswordComponent implements OnInit {
|
||||
if (decryptedUserKey == null) {
|
||||
this.toastService.showToast({
|
||||
variant: "error",
|
||||
title: null,
|
||||
title: "",
|
||||
message: this.i18nService.t("invalidMasterPassword"),
|
||||
});
|
||||
|
||||
|
||||
@@ -61,12 +61,12 @@ export class DefaultChangePasswordService implements ChangePasswordService {
|
||||
request.masterPasswordHash = currentServerMasterKeyHash;
|
||||
request.masterPasswordHint = newPasswordHint;
|
||||
request.newMasterPasswordHash = newServerMasterKeyHash;
|
||||
request.key = newMasterKeyEncryptedUserKey[1].encryptedString;
|
||||
request.key = newMasterKeyEncryptedUserKey[1].encryptedString as string;
|
||||
|
||||
try {
|
||||
await this.masterPasswordApiService.postPassword(request);
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
} catch {
|
||||
throw new Error("Could not change password");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user