From 3f0f5af26a6b98941ec6af269afefe1a3699bfee Mon Sep 17 00:00:00 2001 From: KiruthigaManivannan <162679756+KiruthigaManivannan@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:26:52 +0530 Subject: [PATCH] PM- 2060 Update Two Factor Yubikey dialog (#9010) * PM-2060 Update Two Factor Yubikey Dialog * PM-2060 Removed old code * PM-2060 Added event emitter to capture enabled status * PM-2060 Addressed review comments * PM-2060 Change in html file for existing key options * PM-2060 Addressed the latest comments * PM-2060 Updated remove method as per comments * PM-2060 Added throw error to enable and disbale in base component * tailwind updates to yubikey two factor settings * fixing imports * remove disable dialog when keys are null to use the error toast * PM-2060 Addressed the review comments and fixed conflicts * Removed super.enable removed extra emitter from component class. * fixing adding multiple keys in one session of a dialog. * removed thrown error --------- Co-authored-by: Ike Kottlowski Co-authored-by: Ike <137194738+ike-kottlowski@users.noreply.github.com> --- .../settings/two-factor-base.component.ts | 1 - .../settings/two-factor-setup.component.ts | 12 +- .../two-factor-yubikey.component.html | 194 ++++++++---------- .../settings/two-factor-yubikey.component.ts | 115 ++++++++--- libs/common/src/abstractions/api.service.ts | 4 +- ... update-two-factor-yubikey-otp.request.ts} | 2 +- libs/common/src/services/api.service.ts | 4 +- 7 files changed, 183 insertions(+), 149 deletions(-) rename libs/common/src/auth/models/request/{update-two-factor-yubio-otp.request.ts => update-two-factor-yubikey-otp.request.ts} (67%) diff --git a/apps/web/src/app/auth/settings/two-factor-base.component.ts b/apps/web/src/app/auth/settings/two-factor-base.component.ts index f909f83e78..ac8906641d 100644 --- a/apps/web/src/app/auth/settings/two-factor-base.component.ts +++ b/apps/web/src/app/auth/settings/two-factor-base.component.ts @@ -48,7 +48,6 @@ export abstract class TwoFactorBaseComponent { this.onUpdated.emit(true); } catch (e) { this.logService.error(e); - throw e; } } diff --git a/apps/web/src/app/auth/settings/two-factor-setup.component.ts b/apps/web/src/app/auth/settings/two-factor-setup.component.ts index 6f80f17bd2..8be6c7a3cc 100644 --- a/apps/web/src/app/auth/settings/two-factor-setup.component.ts +++ b/apps/web/src/app/auth/settings/two-factor-setup.component.ts @@ -160,10 +160,12 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy { if (!result) { return; } - const yubiComp = await this.openModal(this.yubikeyModalRef, TwoFactorYubiKeyComponent); - yubiComp.auth(result); - this.twoFactorSetupSubscription = yubiComp.onUpdated - .pipe(first(), takeUntil(this.destroy$)) + const yubiComp: DialogRef = TwoFactorYubiKeyComponent.open( + this.dialogService, + { data: result }, + ); + yubiComp.componentInstance.onUpdated + .pipe(takeUntil(this.destroy$)) .subscribe((enabled: boolean) => { this.updateStatus(enabled, TwoFactorProviderType.Yubikey); }); @@ -266,7 +268,7 @@ export class TwoFactorSetupComponent implements OnInit, OnDestroy { this.modal.close(); } this.providers.forEach((p) => { - if (p.type === type) { + if (p.type === type && enabled !== undefined) { p.enabled = enabled; } }); diff --git a/apps/web/src/app/auth/settings/two-factor-yubikey.component.html b/apps/web/src/app/auth/settings/two-factor-yubikey.component.html index 514ba2ac96..098669d752 100644 --- a/apps/web/src/app/auth/settings/two-factor-yubikey.component.html +++ b/apps/web/src/app/auth/settings/two-factor-yubikey.component.html @@ -1,118 +1,84 @@ -