From 1b928e53dac78f74cbb2d3dc2fdc7db3eed78ad1 Mon Sep 17 00:00:00 2001 From: vinith-kovan Date: Thu, 13 Jun 2024 19:14:31 +0530 Subject: [PATCH] Bug fix - error toast in 2fa --- .../app/auth/settings/two-factor-email.component.ts | 7 ++++--- .../src/auth/components/two-factor.component.ts | 13 +++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/web/src/app/auth/settings/two-factor-email.component.ts b/apps/web/src/app/auth/settings/two-factor-email.component.ts index b0b7c0a64f..666bfd19a8 100644 --- a/apps/web/src/app/auth/settings/two-factor-email.component.ts +++ b/apps/web/src/app/auth/settings/two-factor-email.component.ts @@ -80,13 +80,14 @@ export class TwoFactorEmailComponent extends TwoFactorBaseComponent { submit = async () => { this.formGroup.markAllAsTouched(); - if (this.formGroup.invalid) { - return; - } + if (this.enabled) { await this.disableEmail(); this.onChangeStatus.emit(false); } else { + if (this.formGroup.invalid) { + return; + } await this.enable(); this.onChangeStatus.emit(true); } diff --git a/libs/angular/src/auth/components/two-factor.component.ts b/libs/angular/src/auth/components/two-factor.component.ts index 8e96c48ba0..affcd9aece 100644 --- a/libs/angular/src/auth/components/two-factor.component.ts +++ b/libs/angular/src/auth/components/two-factor.component.ts @@ -225,7 +225,7 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI } } - async submit() { + submit = async () => { await this.setupCaptcha(); if (this.token == null || this.token === "") { @@ -250,14 +250,11 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI this.token = this.token.replace(" ", "").trim(); } - try { - await this.doSubmit(); - } catch { - if (this.selectedProviderType === TwoFactorProviderType.WebAuthn && this.webAuthn != null) { - this.webAuthn.start(); - } + await this.doSubmit(); + if (this.selectedProviderType === TwoFactorProviderType.WebAuthn && this.webAuthn != null) { + this.webAuthn.start(); } - } + }; async doSubmit() { this.formPromise = this.loginStrategyService.logInTwoFactor(