1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00

refactor(set-change-password): [Auth/PM-18206] Update InputPasswordComponent to handle multiple flows (#13745)

Updates the InputPasswordComponent so that it can eventually be used in multiple set/change password scenarios.

Most importantly, this PR adds an InputPasswordFlow enum and @Input so that parent components can dictate which UI elements to show.
This commit is contained in:
rr-bw
2025-04-07 11:58:50 -07:00
committed by GitHub
parent 7f58cee41b
commit 2267876860
20 changed files with 394 additions and 113 deletions

View File

@@ -4,14 +4,36 @@
[policy]="masterPasswordPolicyOptions"
></auth-password-callout>
<bit-form-field
*ngIf="
inputPasswordFlow === InputPasswordFlow.ChangePassword ||
inputPasswordFlow === InputPasswordFlow.ChangePasswordWithOptionalUserKeyRotation
"
>
<bit-label>{{ "currentMasterPass" | i18n }}</bit-label>
<input
id="input-password-form_current-password"
bitInput
type="password"
formControlName="currentPassword"
/>
<button
type="button"
bitIconButton
bitSuffix
bitPasswordInputToggle
[(toggled)]="showPassword"
></button>
</bit-form-field>
<div class="tw-mb-6">
<bit-form-field>
<bit-label>{{ "masterPassword" | i18n }}</bit-label>
<bit-label>{{ "newMasterPass" | i18n }}</bit-label>
<input
id="input-password-form_password"
id="input-password-form_new-password"
bitInput
type="password"
formControlName="password"
formControlName="newPassword"
/>
<button
type="button"
@@ -30,7 +52,7 @@
<tools-password-strength
[showText]="true"
[email]="email"
[password]="formGroup.controls.password.value"
[password]="formGroup.controls.newPassword.value"
(passwordStrengthScore)="getPasswordStrengthScore($event)"
></tools-password-strength>
</div>
@@ -38,10 +60,10 @@
<bit-form-field>
<bit-label>{{ "confirmMasterPassword" | i18n }}</bit-label>
<input
id="input-password-form_confirmed-password"
id="input-password-form_confirm-new-password"
bitInput
type="password"
formControlName="confirmedPassword"
formControlName="confirmNewPassword"
/>
<button
type="button"
@@ -65,16 +87,40 @@
<bit-label>{{ "checkForBreaches" | i18n }}</bit-label>
</bit-form-control>
<button
type="submit"
bitButton
bitFormButton
buttonType="primary"
[block]="btnBlock"
[loading]="loading"
<bit-form-control
*ngIf="inputPasswordFlow === InputPasswordFlow.ChangePasswordWithOptionalUserKeyRotation"
>
{{ buttonText || ("setMasterPassword" | i18n) }}
</button>
<input type="checkbox" bitCheckbox formControlName="rotateUserKey" />
<bit-label>
{{ "rotateAccountEncKey" | i18n }}
<a
href="https://bitwarden.com/help/account-encryption-key/#rotate-your-encryption-key"
target="_blank"
rel="noreferrer"
appA11yTitle="{{ 'impactOfRotatingYourEncryptionKey' | i18n }}"
>
<i class="bwi bwi-question-circle" aria-hidden="true"></i>
</a>
</bit-label>
</bit-form-control>
<div class="tw-flex tw-gap-2" [ngClass]="inlineButtons ? 'tw-flex-row' : 'tw-flex-col'">
<button type="submit" bitButton bitFormButton buttonType="primary" [loading]="loading">
{{ primaryButtonTextStr || ("setMasterPassword" | i18n) }}
</button>
<button
*ngIf="secondaryButtonText"
type="button"
bitButton
bitFormButton
buttonType="secondary"
[loading]="loading"
(click)="onSecondaryButtonClick.emit()"
>
{{ secondaryButtonTextStr }}
</button>
</div>
<bit-error-summary *ngIf="showErrorSummary" [formGroup]="formGroup"></bit-error-summary>
</form>