diff --git a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service.ts b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service.ts index e6f764f57e..4775d08875 100644 --- a/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service.ts +++ b/apps/browser/src/auth/popup/extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service.ts @@ -1,8 +1,7 @@ import { BehaviorSubject, Observable } from "rxjs"; - -import { AnonLayoutWrapperData, AnonLayoutWrapperDataService , DefaultAnonLayoutWrapperDataService } from "@bitwarden/auth/angular"; - +import { AnonLayoutWrapperData, AnonLayoutWrapperDataService } from "@bitwarden/auth/angular"; import { ExtensionAnonLayoutWrapperData } from "./extension-anon-layout-wrapper.component"; +import { DefaultAnonLayoutWrapperDataService } from "@bitwarden/auth/angular"; export class ExtensionAnonLayoutWrapperDataService extends DefaultAnonLayoutWrapperDataService diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index 03b6ca1765..5913cef97d 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -314,22 +314,9 @@ export class LoginComponent implements OnInit, OnDestroy { await this.router.navigate(["/login-with-device"]); } - protected async validateEmail(): Promise { + protected async validateEmail(): Promise { this.formGroup.controls.email.markAsTouched(); - const emailValid = this.formGroup.controls.email.valid; - - if (emailValid) { - this.toggleLoginUiState(LoginUiState.MASTER_PASSWORD_ENTRY); - await this.getLoginWithDevice(this.emailFormControl.value); - - this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({ - pageTitle: { key: "welcomeBack" }, - pageSubtitle: this.emailFormControl.value, - pageIcon: this.Icons.WaveIcon, - }); - - this.loginComponentService.showBackButton(true); - } + return this.formGroup.controls.email.valid; } protected toggleLoginUiState(value: LoginUiState): void { @@ -394,19 +381,27 @@ export class LoginComponent implements OnInit, OnDestroy { } protected async continue(): Promise { - await this.validateEmail(); + if (await this.validateEmail()) { + this.toggleLoginUiState(LoginUiState.MASTER_PASSWORD_ENTRY); + await this.getLoginWithDevice(this.emailFormControl.value); - // TODO: Toast will be replaced with inline error message in PM-3301 - if (!this.formGroup.controls.email.valid) { + this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({ + pageTitle: { key: "welcomeBack" }, + pageSubtitle: this.emailFormControl.value, + pageIcon: this.Icons.WaveIcon, + }); + + this.loginComponentService.showBackButton(true); + + this.focusInput(); + } else { + // TODO: Toast will be replaced with inline error message in PM-3301 this.toastService.showToast({ variant: "error", title: this.i18nService.t("errorOccured"), message: this.i18nService.t("invalidEmail"), }); - return; } - - this.focusInput(); } private async getLoginWithDevice(email: string): Promise {