1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 04:03:29 +00:00

feat(change-password-component): Change Password Update [18720] - Minor fixes.

This commit is contained in:
Patrick Pimentel
2025-06-11 21:19:46 -06:00
parent 0e2d6f0a06
commit 7bae3d9f6b
7 changed files with 23 additions and 10 deletions

View File

@@ -3421,6 +3421,9 @@
"logInRequestSent": {
"message": "Request sent"
},
"masterPasswordChanged": {
"message": "Master password saved"
},
"exposedMasterPassword": {
"message": "Exposed Master Password"
},

View File

@@ -719,7 +719,7 @@ export class NoRouteReuseStrategy implements RouteReuseStrategy {
RouterModule.forRoot(routes, {
useHash: true,
onSameUrlNavigation: "reload",
/*enableTracing: true,*/
enableTracing: true,
}),
],
exports: [RouterModule],

View File

@@ -244,8 +244,7 @@ export class ChangePasswordComponent
await this.masterPasswordApiService.postPassword(request);
this.toastService.showToast({
variant: "success",
title: this.i18nService.t("masterPasswordChanged"),
message: this.i18nService.t("masterPasswordChangedDesc"),
message: this.i18nService.t("masterPasswordChanged"),
});
this.messagingService.send("logout");
} catch {

View File

@@ -43,7 +43,7 @@ export class ChangePasswordComponent implements OnInit {
@Input() inputPasswordFlow: InputPasswordFlow = InputPasswordFlow.ChangePassword;
activeAccount: Account | null = null;
email!: string;
email?: string;
userId?: UserId;
masterPasswordPolicyOptions?: MasterPasswordPolicyOptions;
initializing = true;
@@ -157,8 +157,7 @@ export class ChangePasswordComponent implements OnInit {
this.toastService.showToast({
variant: "success",
title: this.i18nService.t("masterPasswordChanged"),
message: this.i18nService.t("masterPasswordChangedDesc"),
message: this.i18nService.t("masterPasswordChanged"),
});
this.messagingService.send("logout");

View File

@@ -32,7 +32,10 @@ export abstract class ChangePasswordService {
* @param userId the `userId`
* @throws if the `userId`, `currentMasterKey`, or `currentServerMasterKeyHash` is not found
*/
abstract changePassword(passwordInputResult: PasswordInputResult, userId: UserId): Promise<void>;
abstract changePassword(
passwordInputResult: PasswordInputResult,
userId: UserId | null,
): Promise<void>;
/**
* Changes the user's password and re-encrypts the user key with the `newMasterKey`.

View File

@@ -27,7 +27,7 @@ export class DefaultChangePasswordService implements ChangePasswordService {
private async preparePasswordChange(
passwordInputResult: PasswordInputResult,
userId: UserId,
userId: UserId | null,
): Promise<[UserKey, EncString]> {
if (!userId) {
throw new Error("userId not found");
@@ -51,7 +51,7 @@ export class DefaultChangePasswordService implements ChangePasswordService {
);
}
async changePassword(passwordInputResult: PasswordInputResult, userId: UserId) {
async changePassword(passwordInputResult: PasswordInputResult, userId: UserId | null) {
const newMasterKeyEncryptedUserKey = await this.preparePasswordChange(
passwordInputResult,
userId,

View File

@@ -19,7 +19,16 @@ export class MasterPasswordPolicyOptions extends Domain {
enforceOnLogin = false;
static fromResponse(policy: MasterPasswordPolicyResponse): MasterPasswordPolicyOptions {
if (policy == null) {
// Check if the policy is null or if all the values in the response object is null.
// Exclude the response object because the MasterPasswordPolicyResponse extends
// BaseResponse and we should omit that when checking for null values. Doing this
// programmatically makes this less brittle for future contract changes.
if (
policy == null ||
Object.entries(policy)
.filter(([key]) => key !== "response")
.every(([, value]) => value == null)
) {
return null;
}
const options = new MasterPasswordPolicyOptions();