diff --git a/angular/src/components/two-factor.component.ts b/angular/src/components/two-factor.component.ts index 69c591cb..16a5873a 100644 --- a/angular/src/components/two-factor.component.ts +++ b/angular/src/components/two-factor.component.ts @@ -67,7 +67,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { } async ngOnInit() { - if (!this.authing || this.twoFactorService.providers == null) { + if (!this.authing || this.twoFactorService.getProviders() == null) { this.router.navigate([this.loginRoute]); return; } @@ -122,7 +122,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { this.cleanupWebAuthn(); this.title = (TwoFactorProviders as any)[this.selectedProviderType].name; - const providerData = this.twoFactorService.providers.get(this.selectedProviderType); + const providerData = this.twoFactorService.getProviders().get(this.selectedProviderType); switch (this.selectedProviderType) { case TwoFactorProviderType.WebAuthn: if (!this.webAuthnNewTab) { @@ -150,7 +150,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { break; case TwoFactorProviderType.Email: this.twoFactorEmail = providerData.Email; - if (this.twoFactorService.providers.size > 1) { + if (this.twoFactorService.getProviders().size > 1) { await this.sendEmail(false); } break; @@ -250,7 +250,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { } authWebAuthn() { - const providerData = this.twoFactorService.providers.get(this.selectedProviderType); + const providerData = this.twoFactorService.getProviders().get(this.selectedProviderType); if (!this.webAuthnSupported || this.webAuthn == null) { return; diff --git a/common/src/abstractions/twoFactor.service.ts b/common/src/abstractions/twoFactor.service.ts index 009ac386..701276de 100644 --- a/common/src/abstractions/twoFactor.service.ts +++ b/common/src/abstractions/twoFactor.service.ts @@ -4,8 +4,10 @@ export abstract class TwoFactorService { init: () => void; getSupportedProviders: (win: Window) => any[]; getDefaultProvider: (webAuthnSupported: boolean) => TwoFactorProviderType; + setSelectedProvider: (type: TwoFactorProviderType) => void; clearSelectedProvider: () => void; + setProviders: (data: any) => void; clearProviders: () => void; - providers: Map; + getProviders: () => Map; } diff --git a/common/src/services/twoFactor.service.ts b/common/src/services/twoFactor.service.ts index f4eaeebf..05e37921 100644 --- a/common/src/services/twoFactor.service.ts +++ b/common/src/services/twoFactor.service.ts @@ -159,6 +159,10 @@ export class TwoFactorService implements TwoFactorServiceAbstraction { return providerType; } + setSelectedProvider(type: TwoFactorProviderType) { + this.selectedTwoFactorProviderType = type; + } + clearSelectedProvider() { this.selectedTwoFactorProviderType = null; }