mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
Simplify validateEmail method
This commit is contained in:
parent
8889ed3d3c
commit
c9141a1cb5
@ -1,8 +1,7 @@
|
|||||||
import { BehaviorSubject, Observable } from "rxjs";
|
import { BehaviorSubject, Observable } from "rxjs";
|
||||||
|
import { AnonLayoutWrapperData, AnonLayoutWrapperDataService } from "@bitwarden/auth/angular";
|
||||||
import { AnonLayoutWrapperData, AnonLayoutWrapperDataService , DefaultAnonLayoutWrapperDataService } from "@bitwarden/auth/angular";
|
|
||||||
|
|
||||||
import { ExtensionAnonLayoutWrapperData } from "./extension-anon-layout-wrapper.component";
|
import { ExtensionAnonLayoutWrapperData } from "./extension-anon-layout-wrapper.component";
|
||||||
|
import { DefaultAnonLayoutWrapperDataService } from "@bitwarden/auth/angular";
|
||||||
|
|
||||||
export class ExtensionAnonLayoutWrapperDataService
|
export class ExtensionAnonLayoutWrapperDataService
|
||||||
extends DefaultAnonLayoutWrapperDataService
|
extends DefaultAnonLayoutWrapperDataService
|
||||||
|
@ -314,22 +314,9 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||||||
await this.router.navigate(["/login-with-device"]);
|
await this.router.navigate(["/login-with-device"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async validateEmail(): Promise<void> {
|
protected async validateEmail(): Promise<boolean> {
|
||||||
this.formGroup.controls.email.markAsTouched();
|
this.formGroup.controls.email.markAsTouched();
|
||||||
const emailValid = this.formGroup.controls.email.valid;
|
return 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected toggleLoginUiState(value: LoginUiState): void {
|
protected toggleLoginUiState(value: LoginUiState): void {
|
||||||
@ -394,19 +381,27 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async continue(): Promise<void> {
|
protected async continue(): Promise<void> {
|
||||||
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
|
this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({
|
||||||
if (!this.formGroup.controls.email.valid) {
|
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({
|
this.toastService.showToast({
|
||||||
variant: "error",
|
variant: "error",
|
||||||
title: this.i18nService.t("errorOccured"),
|
title: this.i18nService.t("errorOccured"),
|
||||||
message: this.i18nService.t("invalidEmail"),
|
message: this.i18nService.t("invalidEmail"),
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focusInput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getLoginWithDevice(email: string): Promise<void> {
|
private async getLoginWithDevice(email: string): Promise<void> {
|
||||||
|
Loading…
Reference in New Issue
Block a user