1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-02 03:21:19 +00:00

[PM-18721] update enum to be uniform and update enum docs

This commit is contained in:
rr-bw
2025-05-06 14:51:48 -07:00
parent 434c92077d
commit 60287ce9c5
5 changed files with 45 additions and 36 deletions

View File

@@ -53,26 +53,33 @@ import { PasswordInputResult } from "./password-input-result";
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum InputPasswordFlow {
/**
* Form elements displayed:
* - [Input] New password
* - [Input] New password confirm
* Form Fields: `[newPassword, newPasswordConfirm, newPasswordHint, checkForBreaches]`
*
* Note: this flow does not involve an active account `userId`
*/
ChangePasswordDelegation,
SetInitialPasswordAccountRegistration,
/**
* All form elements above, plus:
* - [Input] New password hint
* - [Checkbox] Check for breaches
* Form Fields: `[newPassword, newPasswordConfirm, newPasswordHint, checkForBreaches]`
*/
AccountRegistration, // important: this flow does not involve an activeAccount/userId
SetInitialPasswordAuthedUser,
/*
* All form elements above, plus: [Input] Current password (as the first element in the UI)
/**
* Form Fields: `[currentPassword, newPassword, newPasswordConfirm, newPasswordHint, checkForBreaches]`
*/
ChangePassword,
/**
* All form elements above, plus: [Checkbox] Rotate account encryption key (as the last element in the UI)
* Form Fields: `[currentPassword, newPassword, newPasswordConfirm, newPasswordHint, checkForBreaches, rotateUserKey]`
*/
ChangePasswordWithOptionalUserKeyRotation,
/**
* This flow is used when a user changes the password for another user's account, such as:
* - Emergency Access Takeover
* - Account Recovery
*
* Form Fields: `[newPassword, newPasswordConfirm]`
*
* Note: this flow does not involve an active account `email`
*/
ChangePasswordDelegation,
}
interface InputPasswordForm {
@@ -278,7 +285,7 @@ export class InputPasswordComponent implements OnInit {
const checkForBreaches = this.formGroup.controls.checkForBreaches?.value ?? true;
// 1. Determine kdfConfig
if (this.flow === InputPasswordFlow.AccountRegistration) {
if (this.flow === InputPasswordFlow.SetInitialPasswordAccountRegistration) {
this.kdfConfig = DEFAULT_KDF_CONFIG;
} else {
if (!this.userId) {
@@ -394,7 +401,7 @@ export class InputPasswordComponent implements OnInit {
* from the parent component.
*/
if (
this.flow === InputPasswordFlow.AccountRegistration ||
this.flow === InputPasswordFlow.SetInitialPasswordAccountRegistration ||
this.flow === InputPasswordFlow.ChangePasswordDelegation
) {
if (this.userId) {
@@ -411,7 +418,7 @@ export class InputPasswordComponent implements OnInit {
* (b) passed down the correct InputPasswordFlow but failed to pass down a userId
*/
if (
this.flow !== InputPasswordFlow.AccountRegistration &&
this.flow !== InputPasswordFlow.SetInitialPasswordAccountRegistration &&
this.flow !== InputPasswordFlow.ChangePasswordDelegation
) {
if (!this.userId) {