mirror of
https://github.com/bitwarden/jslib
synced 2025-12-19 09:43:28 +00:00
Update twoFactorService interface
This commit is contained in:
@@ -67,7 +67,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
if (!this.authing || this.twoFactorService.providers == null) {
|
if (!this.authing || this.twoFactorService.getProviders() == null) {
|
||||||
this.router.navigate([this.loginRoute]);
|
this.router.navigate([this.loginRoute]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.cleanupWebAuthn();
|
this.cleanupWebAuthn();
|
||||||
this.title = (TwoFactorProviders as any)[this.selectedProviderType].name;
|
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) {
|
switch (this.selectedProviderType) {
|
||||||
case TwoFactorProviderType.WebAuthn:
|
case TwoFactorProviderType.WebAuthn:
|
||||||
if (!this.webAuthnNewTab) {
|
if (!this.webAuthnNewTab) {
|
||||||
@@ -150,7 +150,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
|
|||||||
break;
|
break;
|
||||||
case TwoFactorProviderType.Email:
|
case TwoFactorProviderType.Email:
|
||||||
this.twoFactorEmail = providerData.Email;
|
this.twoFactorEmail = providerData.Email;
|
||||||
if (this.twoFactorService.providers.size > 1) {
|
if (this.twoFactorService.getProviders().size > 1) {
|
||||||
await this.sendEmail(false);
|
await this.sendEmail(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -250,7 +250,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
authWebAuthn() {
|
authWebAuthn() {
|
||||||
const providerData = this.twoFactorService.providers.get(this.selectedProviderType);
|
const providerData = this.twoFactorService.getProviders().get(this.selectedProviderType);
|
||||||
|
|
||||||
if (!this.webAuthnSupported || this.webAuthn == null) {
|
if (!this.webAuthnSupported || this.webAuthn == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ export abstract class TwoFactorService {
|
|||||||
init: () => void;
|
init: () => void;
|
||||||
getSupportedProviders: (win: Window) => any[];
|
getSupportedProviders: (win: Window) => any[];
|
||||||
getDefaultProvider: (webAuthnSupported: boolean) => TwoFactorProviderType;
|
getDefaultProvider: (webAuthnSupported: boolean) => TwoFactorProviderType;
|
||||||
|
setSelectedProvider: (type: TwoFactorProviderType) => void;
|
||||||
clearSelectedProvider: () => void;
|
clearSelectedProvider: () => void;
|
||||||
|
|
||||||
setProviders: (data: any) => void;
|
setProviders: (data: any) => void;
|
||||||
clearProviders: () => void;
|
clearProviders: () => void;
|
||||||
providers: Map<TwoFactorProviderType, { [key: string]: string }>;
|
getProviders: () => Map<TwoFactorProviderType, { [key: string]: string }>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ export class TwoFactorService implements TwoFactorServiceAbstraction {
|
|||||||
return providerType;
|
return providerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSelectedProvider(type: TwoFactorProviderType) {
|
||||||
|
this.selectedTwoFactorProviderType = type;
|
||||||
|
}
|
||||||
|
|
||||||
clearSelectedProvider() {
|
clearSelectedProvider() {
|
||||||
this.selectedTwoFactorProviderType = null;
|
this.selectedTwoFactorProviderType = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user