mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Populate email on registration start form.
This commit is contained in:
@@ -6,9 +6,12 @@ import { Subject, takeUntil } from "rxjs";
|
|||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
||||||
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { RegisterSendVerificationEmailRequest } from "@bitwarden/common/auth/models/request/registration/register-send-verification-email.request";
|
import { RegisterSendVerificationEmailRequest } from "@bitwarden/common/auth/models/request/registration/register-send-verification-email.request";
|
||||||
import { RegionConfig, Region } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { RegionConfig, Region } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||||
import {
|
import {
|
||||||
AsyncActionsModule,
|
AsyncActionsModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
@@ -18,6 +21,7 @@ import {
|
|||||||
LinkModule,
|
LinkModule,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
|
||||||
|
import { LoginEmailService } from "../../../common";
|
||||||
import { RegistrationCheckEmailIcon } from "../../icons/registration-check-email.icon";
|
import { RegistrationCheckEmailIcon } from "../../icons/registration-check-email.icon";
|
||||||
import { RegistrationEnvSelectorComponent } from "../registration-env-selector/registration-env-selector.component";
|
import { RegistrationEnvSelectorComponent } from "../registration-env-selector/registration-env-selector.component";
|
||||||
|
|
||||||
@@ -48,6 +52,17 @@ const DEFAULT_MARKETING_EMAILS_PREF_BY_REGION: Record<Region, boolean> = {
|
|||||||
IconModule,
|
IconModule,
|
||||||
RegistrationEnvSelectorComponent,
|
RegistrationEnvSelectorComponent,
|
||||||
],
|
],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: LoginEmailService,
|
||||||
|
useFactory: (
|
||||||
|
accountService: AccountService,
|
||||||
|
authService: AuthService,
|
||||||
|
stateProvider: StateProvider,
|
||||||
|
) => new LoginEmailService(accountService, authService, stateProvider),
|
||||||
|
deps: [AccountService, AuthService, StateProvider],
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class RegistrationStartComponent implements OnInit, OnDestroy {
|
export class RegistrationStartComponent implements OnInit, OnDestroy {
|
||||||
@Output() registrationStartStateChange = new EventEmitter<RegistrationStartState>();
|
@Output() registrationStartStateChange = new EventEmitter<RegistrationStartState>();
|
||||||
@@ -88,6 +103,7 @@ export class RegistrationStartComponent implements OnInit, OnDestroy {
|
|||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private accountApiService: AccountApiService,
|
private accountApiService: AccountApiService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private loginEmailService: LoginEmailService,
|
||||||
) {
|
) {
|
||||||
this.isSelfHost = platformUtilsService.isSelfHost();
|
this.isSelfHost = platformUtilsService.isSelfHost();
|
||||||
}
|
}
|
||||||
@@ -97,6 +113,15 @@ export class RegistrationStartComponent implements OnInit, OnDestroy {
|
|||||||
this.registrationStartStateChange.emit(this.state);
|
this.registrationStartStateChange.emit(this.state);
|
||||||
|
|
||||||
this.listenForQueryParamChanges();
|
this.listenForQueryParamChanges();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the user has a login email, set the email field to the login email.
|
||||||
|
*/
|
||||||
|
this.loginEmailService.loginEmail$.pipe(takeUntil(this.destroy$)).subscribe((email) => {
|
||||||
|
if (email) {
|
||||||
|
this.formGroup.patchValue({ email });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private listenForQueryParamChanges() {
|
private listenForQueryParamChanges() {
|
||||||
|
|||||||
Reference in New Issue
Block a user