mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[PM-11136] Convert LoginEmailService email property to state provider (#10624)
* convert email property to state provider * update tests * assign loginEmail to variable before passing in * remove nav logic in ngOnInit
This commit is contained in:
@@ -41,7 +41,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
const email = this.loginEmailService.getEmail();
|
||||
const email = await firstValueFrom(this.loginEmailService.loginEmail$);
|
||||
const rememberEmail = this.loginEmailService.getRememberEmail();
|
||||
|
||||
if (email != null) {
|
||||
@@ -93,7 +93,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
async setLoginEmailValues() {
|
||||
// Note: Browser saves email settings here instead of the login component
|
||||
this.loginEmailService.setRememberEmail(this.formGroup.value.rememberEmail);
|
||||
this.loginEmailService.setEmail(this.formGroup.value.email);
|
||||
await this.loginEmailService.setLoginEmail(this.formGroup.value.email);
|
||||
await this.loginEmailService.saveEmailSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, NgZone } from "@angular/core";
|
||||
import { Component, NgZone, OnInit } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
@@ -31,7 +31,7 @@ import { flagEnabled } from "../../platform/flags";
|
||||
selector: "app-login",
|
||||
templateUrl: "login.component.html",
|
||||
})
|
||||
export class LoginComponent extends BaseLoginComponent {
|
||||
export class LoginComponent extends BaseLoginComponent implements OnInit {
|
||||
showPasswordless = false;
|
||||
constructor(
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
@@ -83,13 +83,14 @@ export class LoginComponent extends BaseLoginComponent {
|
||||
};
|
||||
super.successRoute = "/tabs/vault";
|
||||
this.showPasswordless = flagEnabled("showPasswordless");
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
if (this.showPasswordless) {
|
||||
this.formGroup.controls.email.setValue(this.loginEmailService.getEmail());
|
||||
const loginEmail = await firstValueFrom(this.loginEmailService.loginEmail$);
|
||||
this.formGroup.controls.email.setValue(loginEmail);
|
||||
this.formGroup.controls.rememberEmail.setValue(this.loginEmailService.getRememberEmail());
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.validateEmail();
|
||||
await this.validateEmail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ export class HintComponent extends BaseHintComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
async ngOnInit(): Promise<void> {
|
||||
await super.ngOnInit();
|
||||
this.emailFormControl.setValue(this.email);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user