1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-03 17:13:47 +00:00

fix email 2fa validation (#9702)

This commit is contained in:
Jake Fink
2024-06-17 17:26:52 -04:00
committed by GitHub
parent 8440759602
commit 75615902a3
2 changed files with 37 additions and 11 deletions

View File

@@ -41,6 +41,7 @@ export abstract class TwoFactorBaseComponent {
this.authed = true;
}
/** @deprecated used for formPromise flows.*/
protected async enable(enableFunction: () => Promise<void>) {
try {
await enableFunction();
@@ -50,6 +51,10 @@ export abstract class TwoFactorBaseComponent {
}
}
/**
* @deprecated used for formPromise flows.
* TODO: Remove this method when formPromises are removed from all flows.
* */
protected async disable(promise: Promise<unknown>) {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "disable" },
@@ -78,6 +83,29 @@ export abstract class TwoFactorBaseComponent {
}
}
protected async disableMethod() {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "disable" },
content: { key: "twoStepDisableDesc" },
type: "warning",
});
if (!confirmed) {
return;
}
const request = await this.buildRequestModel(TwoFactorProviderRequest);
request.type = this.type;
if (this.organizationId != null) {
await this.apiService.putTwoFactorOrganizationDisable(this.organizationId, request);
} else {
await this.apiService.putTwoFactorDisable(request);
}
this.enabled = false;
this.platformUtilsService.showToast("success", null, this.i18nService.t("twoStepDisabled"));
this.onUpdated.emit(false);
}
protected async buildRequestModel<T extends SecretVerificationRequest>(
requestClass: new () => T,
) {