1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-16 01:21:48 +01:00

PM-8113 - TwoFactorAuthComponent - add setAnonLayoutDataByTwoFactorProviderType and handle email case as POC

This commit is contained in:
Jared Snider 2025-01-27 19:07:37 -05:00
parent 94f151779b
commit ab38b3bd89
No known key found for this signature in database
GPG Key ID: A149DDD612516286
4 changed files with 33 additions and 10 deletions

View File

@ -860,6 +860,9 @@
"logInToBitwarden": {
"message": "Log in to Bitwarden"
},
"enterTheCodeSentToYourEmail": {
"message": "Enter the code sent to your email"
},
"restartRegistration": {
"message": "Restart registration"
},

View File

@ -652,6 +652,9 @@
"logInToBitwarden": {
"message": "Log in to Bitwarden"
},
"enterTheCodeSentToYourEmail": {
"message": "Enter the code sent to your email"
},
"logInWithPasskey": {
"message": "Log in with passkey"
},

View File

@ -1179,6 +1179,9 @@
"logInToBitwarden": {
"message": "Log in to Bitwarden"
},
"enterTheCodeSentToYourEmail": {
"message": "Enter the code sent to your email"
},
"authenticationTimeout": {
"message": "Authentication timeout"
},

View File

@ -37,6 +37,9 @@ import {
ToastService,
} from "@bitwarden/components";
import { AnonLayoutWrapperDataService } from "../anon-layout/anon-layout-wrapper-data.service";
import { TwoFactorAuthEmailIcon } from "../icons/two-factor-auth";
import { TwoFactorAuthAuthenticatorComponent } from "./child-components/two-factor-auth-authenticator.component";
import { TwoFactorAuthDuoComponent } from "./child-components/two-factor-auth-duo/two-factor-auth-duo.component";
import { TwoFactorAuthEmailComponent } from "./child-components/two-factor-auth-email/two-factor-auth-email.component";
@ -104,8 +107,6 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
remember: [false],
});
title = "";
formPromise: Promise<any> | undefined;
submitForm = async () => {
@ -134,6 +135,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
private twoFactorAuthComponentService: TwoFactorAuthComponentService,
private syncService: SyncService,
private destroyRef: DestroyRef,
private anonLayoutWrapperDataService: AnonLayoutWrapperDataService,
) {}
async ngOnInit() {
@ -146,7 +148,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
await this.setSelected2faProviderType();
await this.set2faProviderData();
await this.setTitleByTwoFactorProviderType();
await this.setAnonLayoutDataByTwoFactorProviderType();
this.form.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
if (value.token) {
@ -261,7 +263,7 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
});
this.providerData = providerData;
this.selectedProviderType = response.type;
await this.setTitleByTwoFactorProviderType();
await this.setAnonLayoutDataByTwoFactorProviderType();
}
}
@ -294,13 +296,25 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
return true;
}
async setTitleByTwoFactorProviderType() {
if (this.selectedProviderType == null) {
this.title = this.i18nService.t("loginUnavailable");
return;
}
async setAnonLayoutDataByTwoFactorProviderType() {
switch (this.selectedProviderType) {
// case TwoFactorProviderType.Authenticator:
// this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({
// pageTitle: this.i18nService.t("ADD ME"),
// pageSubtitle: this.i18nService.t("twoFactorAuthenticatorSubtitle"),
// pageIcon: TwoFactorAuthAuthenticatorIcon,
// });
// break;
case TwoFactorProviderType.Email:
this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({
pageSubtitle: this.i18nService.t("enterTheCodeSentToYourEmail"),
pageIcon: TwoFactorAuthEmailIcon,
});
break;
this.title = (TwoFactorProviders as any)[this.selectedProviderType].name;
default:
break;
}
}
private async handleAuthResult(authResult: AuthResult) {