1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-27 10:03:23 +00:00

[PM-18721] add ChangePasswordDelegation logic to InputPasswordComponent submit method

This commit is contained in:
rr-bw
2025-05-04 22:31:17 -07:00
parent c428a4078a
commit 434c92077d
6 changed files with 37 additions and 17 deletions

View File

@@ -10,17 +10,14 @@
}}</bit-callout>
<auth-input-password
*ngIf="!initializing"
[flow]="inputPasswordFlow"
[masterPasswordPolicyOptions]="masterPasswordPolicyOptions"
(onPasswordFormSubmit)="handlePasswordFormSubmit($event)"
></auth-input-password>
<auth-change-password [inputPasswordFlow]="inputPasswordFlow"></auth-change-password>
</div>
<ng-container bitDialogFooter>
<button type="submit" bitButton bitFormButton buttonType="primary">
<button type="button" bitButton bitFormButton buttonType="primary" (click)="submit()">
{{ "save" | i18n }}
</button>
<button type="button" bitButton bitFormButton buttonType="secondary" bitDialogClose>

View File

@@ -1,9 +1,8 @@
import { CommonModule } from "@angular/common";
import { Component, Inject, OnInit } from "@angular/core";
import { Component, Inject, OnInit, ViewChild } from "@angular/core";
import { firstValueFrom } from "rxjs";
import {
ChangePasswordComponent,
InputPasswordComponent,
InputPasswordFlow,
PasswordInputResult,
@@ -54,7 +53,6 @@ export enum EmergencyAccessTakeoverDialogResultType {
ButtonModule,
CommonModule,
CalloutModule,
ChangePasswordComponent,
DialogModule,
FormFieldModule,
I18nPipe,
@@ -62,9 +60,10 @@ export enum EmergencyAccessTakeoverDialogResultType {
],
})
export class EmergencyAccessTakeoverDialogComponent implements OnInit {
inputPasswordFlow = InputPasswordFlow.ChangePasswordDelegation;
@ViewChild(InputPasswordComponent)
inputPasswordComponent: InputPasswordComponent;
initializing = true;
inputPasswordFlow = InputPasswordFlow.ChangePasswordDelegation;
masterPasswordPolicyOptions?: MasterPasswordPolicyOptions;
constructor(
@@ -91,6 +90,10 @@ export class EmergencyAccessTakeoverDialogComponent implements OnInit {
);
}
submit = async () => {
await this.inputPasswordComponent.submit();
};
async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) {
try {
await this.emergencyAccessService.takeover(

View File

@@ -122,7 +122,11 @@
</bit-label>
</bit-form-control>
<div class="tw-flex tw-gap-2" [ngClass]="inlineButtons ? 'tw-flex-row' : 'tw-flex-col'">
<div
*ngIf="flow !== InputPasswordFlow.ChangePasswordDelegation"
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>

View File

@@ -246,7 +246,7 @@ export class InputPasswordComponent implements OnInit {
}
}
protected submit = async () => {
submit = async () => {
this.verifyFlow();
this.formGroup.markAllAsTouched();
@@ -256,6 +256,18 @@ export class InputPasswordComponent implements OnInit {
return;
}
if (this.flow === InputPasswordFlow.ChangePasswordDelegation) {
const newPassword = this.formGroup.controls.newPassword.value;
const passwordInputResult: PasswordInputResult = {
newPassword,
};
this.onPasswordFormSubmit.emit(passwordInputResult);
return;
}
if (!this.email) {
throw new Error("Email is required to create master key.");
}

View File

@@ -8,11 +8,11 @@ export interface PasswordInputResult {
currentLocalMasterKeyHash?: string;
newPassword: string;
newPasswordHint: string;
newMasterKey: MasterKey;
newServerMasterKeyHash: string;
newLocalMasterKeyHash: string;
newPasswordHint?: string;
newMasterKey?: MasterKey;
newServerMasterKeyHash?: string;
newLocalMasterKeyHash?: string;
kdfConfig: KdfConfig;
kdfConfig?: KdfConfig;
rotateUserKey?: boolean;
}

View File

@@ -98,7 +98,11 @@ export class SetPasswordJitComponent implements OnInit {
this.submitting = true;
const credentials: SetPasswordCredentials = {
...passwordInputResult,
newMasterKey: passwordInputResult.newMasterKey,
newServerMasterKeyHash: passwordInputResult.newServerMasterKeyHash,
newLocalMasterKeyHash: passwordInputResult.newLocalMasterKeyHash,
newPasswordHint: passwordInputResult.newPasswordHint,
kdfConfig: passwordInputResult.kdfConfig,
orgSsoIdentifier: this.orgSsoIdentifier,
orgId: this.orgId,
resetPasswordAutoEnroll: this.resetPasswordAutoEnroll,