From ff387622e0e8bbfb45a6a06da5eb86c8da9d763d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 7 Jun 2021 18:38:15 +0200 Subject: [PATCH] Add button to open webauthn new tab (#398) --- .../src/components/two-factor.component.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/angular/src/components/two-factor.component.ts b/angular/src/components/two-factor.component.ts index b149bcb7ca..f8dc22e374 100644 --- a/angular/src/components/two-factor.component.ts +++ b/angular/src/components/two-factor.component.ts @@ -114,13 +114,11 @@ export class TwoFactorComponent implements OnInit, OnDestroy { const providerData = this.authService.twoFactorProvidersData.get(this.selectedProviderType); switch (this.selectedProviderType) { case TwoFactorProviderType.WebAuthn: - if (!this.webAuthnSupported || this.webAuthn == null) { - break; + if (!this.webAuthnNewTab) { + setTimeout(() => { + this.authWebAuthn(); + }, 500); } - - setTimeout(() => { - this.webAuthn.init(providerData); - }, 500); break; case TwoFactorProviderType.Duo: case TwoFactorProviderType.OrganizationDuo: @@ -221,6 +219,16 @@ export class TwoFactorComponent implements OnInit, OnDestroy { this.emailPromise = null; } + authWebAuthn() { + const providerData = this.authService.twoFactorProvidersData.get(this.selectedProviderType); + + if (!this.webAuthnSupported || this.webAuthn == null) { + return; + } + + this.webAuthn.init(providerData); + } + private cleanupWebAuthn() { if (this.webAuthn != null) { this.webAuthn.stop();