mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 04:03:29 +00:00
feat(change-password-component): Change Password Update [18720] - Committing intermediate changes.
This commit is contained in:
@@ -130,6 +130,8 @@ export class SetPasswordComponent extends BaseChangePasswordComponent implements
|
||||
this.resetPasswordAutoEnroll = orgAutoEnrollStatusResponse.resetPasswordEnabled;
|
||||
}),
|
||||
switchMap((orgAutoEnrollStatusResponse: OrganizationAutoEnrollStatusResponse) =>
|
||||
// Does this actually need to confirm for all organizations.
|
||||
|
||||
// Must get org id from response to get master password policy options
|
||||
this.policyApiService.getMasterPasswordPolicyOptsForOrgUser(
|
||||
orgAutoEnrollStatusResponse.id,
|
||||
|
||||
@@ -31,9 +31,9 @@ export class AnonLayoutComponent implements OnInit, OnChanges {
|
||||
return ["tw-h-full"];
|
||||
}
|
||||
|
||||
@Input() title?: string;
|
||||
@Input() subtitle?: string;
|
||||
@Input() icon?: Icon;
|
||||
@Input() title: string;
|
||||
@Input() subtitle: string;
|
||||
@Input() icon: Icon;
|
||||
@Input() showReadonlyHostname?: boolean;
|
||||
@Input() hideLogo: boolean = false;
|
||||
@Input() hideFooter: boolean = false;
|
||||
@@ -56,8 +56,8 @@ export class AnonLayoutComponent implements OnInit, OnChanges {
|
||||
protected logo = BitwardenLogo;
|
||||
protected year: string;
|
||||
protected clientType: ClientType;
|
||||
protected hostname?: string;
|
||||
protected version?: string;
|
||||
protected hostname: string;
|
||||
protected version: string;
|
||||
|
||||
protected hideYearAndVersion = false;
|
||||
|
||||
|
||||
@@ -15,12 +15,7 @@
|
||||
[inlineButtons]="true"
|
||||
[primaryButtonText]="{ key: 'changeMasterPassword' }"
|
||||
(onPasswordFormSubmit)="handlePasswordFormSubmit($event)"
|
||||
[secondaryButtonText]="
|
||||
this.forceSetPasswordReason === ForceSetPasswordReason.AdminForcePasswordReset ||
|
||||
this.forceSetPasswordReason === ForceSetPasswordReason.WeakMasterPassword
|
||||
? { key: 'logOut' }
|
||||
: undefined
|
||||
"
|
||||
[secondaryButtonText]="shouldShowLogoutText()"
|
||||
(onSecondaryButtonClick)="logOut()"
|
||||
[showChangePasswordWarning]="
|
||||
this.forceSetPasswordReason !== ForceSetPasswordReason.AdminForcePasswordReset
|
||||
|
||||
@@ -52,6 +52,8 @@ export class ChangePasswordComponent implements OnInit {
|
||||
formPromise?: Promise<any>;
|
||||
forceSetPasswordReason: ForceSetPasswordReason = ForceSetPasswordReason.None;
|
||||
|
||||
protected readonly ForceSetPasswordReason = ForceSetPasswordReason;
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
private changePasswordService: ChangePasswordService,
|
||||
@@ -77,7 +79,7 @@ export class ChangePasswordComponent implements OnInit {
|
||||
this.email = this.activeAccount.email;
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Error("activeUserId not found");
|
||||
throw new Error("userId not found");
|
||||
}
|
||||
|
||||
this.masterPasswordPolicyOptions = await firstValueFrom(
|
||||
@@ -174,5 +176,13 @@ export class ChangePasswordComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly ForceSetPasswordReason = ForceSetPasswordReason;
|
||||
/**
|
||||
* Shows the logout button in the case of admin force reset password or weak password upon login.
|
||||
*/
|
||||
protected shouldShowLogoutText(): { key: string } | undefined {
|
||||
return this.forceSetPasswordReason === ForceSetPasswordReason.AdminForcePasswordReset ||
|
||||
this.forceSetPasswordReason === ForceSetPasswordReason.WeakMasterPassword
|
||||
? { key: "logOut" }
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ describe("DefaultChangePasswordService", () => {
|
||||
|
||||
it("should throw if a userId was not found", async () => {
|
||||
// Arrange
|
||||
const userId: undefined = undefined;
|
||||
const userId: null = null;
|
||||
|
||||
// Act
|
||||
const testFn = sut.changePassword(passwordInputResult, userId);
|
||||
@@ -109,7 +109,7 @@ describe("DefaultChangePasswordService", () => {
|
||||
it("should throw if a currentMasterKey was not found", async () => {
|
||||
// Arrange
|
||||
const incorrectPasswordInputResult = { ...passwordInputResult };
|
||||
incorrectPasswordInputResult.currentMasterKey = undefined;
|
||||
incorrectPasswordInputResult.currentMasterKey = null;
|
||||
|
||||
// Act
|
||||
const testFn = sut.changePassword(incorrectPasswordInputResult, userId);
|
||||
@@ -123,7 +123,7 @@ describe("DefaultChangePasswordService", () => {
|
||||
it("should throw if a currentServerMasterKeyHash was not found", async () => {
|
||||
// Arrange
|
||||
const incorrectPasswordInputResult = { ...passwordInputResult };
|
||||
incorrectPasswordInputResult.currentServerMasterKeyHash = undefined;
|
||||
incorrectPasswordInputResult.currentServerMasterKeyHash = null;
|
||||
|
||||
// Act
|
||||
const testFn = sut.changePassword(incorrectPasswordInputResult, userId);
|
||||
|
||||
@@ -58,7 +58,7 @@ export class DefaultChangePasswordService implements ChangePasswordService {
|
||||
);
|
||||
|
||||
const request = new PasswordRequest();
|
||||
request.masterPasswordHash = passwordInputResult.currentServerMasterKeyHash ?? "";
|
||||
request.masterPasswordHash = passwordInputResult.currentServerMasterKeyHash;
|
||||
request.newMasterPasswordHash = passwordInputResult.newServerMasterKeyHash;
|
||||
request.masterPasswordHint = passwordInputResult.newPasswordHint;
|
||||
request.key = newMasterKeyEncryptedUserKey[1].encryptedString as string;
|
||||
|
||||
@@ -163,7 +163,7 @@ export class InputPasswordComponent implements OnInit {
|
||||
|
||||
protected get minPasswordLengthMsg() {
|
||||
if (
|
||||
this.masterPasswordPolicyOptions != null &&
|
||||
this.masterPasswordPolicyOptions != undefined &&
|
||||
this.masterPasswordPolicyOptions.minLength > 0
|
||||
) {
|
||||
return this.i18nService.t("characterMinimum", this.masterPasswordPolicyOptions.minLength);
|
||||
|
||||
@@ -244,6 +244,9 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
: null;
|
||||
|
||||
const orgMasterPasswordPolicyOptions = orgPoliciesFromInvite?.enforcedPasswordPolicyOptions;
|
||||
|
||||
// Grab the org policies from invite so that it can be evaluated after we have logged in and
|
||||
// received a user id.
|
||||
this.passwordPoliciesFromOrgInvite = orgPoliciesFromInvite?.policies;
|
||||
|
||||
credentials = new PasswordLoginCredentials(
|
||||
@@ -342,11 +345,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
// Check if we have policies to set from an org invite scenario.
|
||||
if (this.passwordPoliciesFromOrgInvite) {
|
||||
await this.setPoliciesIntoState(authResult.userId, this.passwordPoliciesFromOrgInvite);
|
||||
|
||||
// Short circuit here so that we prevent the accept organization invite from prematurely
|
||||
// accepting the org invite by getting routed away to vault.
|
||||
// await this.router.navigate(["change-password"]);
|
||||
// return;
|
||||
}
|
||||
} else {
|
||||
// TODO: PM-18269 - evaluate if we can combine this with the
|
||||
|
||||
@@ -82,6 +82,7 @@ export class SetPasswordJitComponent implements OnInit {
|
||||
);
|
||||
this.orgId = autoEnrollStatus.id;
|
||||
this.resetPasswordAutoEnroll = autoEnrollStatus.resetPasswordEnabled;
|
||||
// Does this actually need to confirm for all organizations.
|
||||
this.masterPasswordPolicyOptions =
|
||||
await this.policyApiService.getMasterPasswordPolicyOptsForOrgUser(autoEnrollStatus.id);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user