diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index 34f0286b33..ff33e56aec 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -113,26 +113,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { await this.webOnInit(); } - let paramEmailIsSet = false; - - this.activatedRoute.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => { - if (!params) { - return; - } - - const qParamsEmail = params.email; - - // If there is an email in the query params, set that email as the form field value - if (qParamsEmail?.indexOf("@") > -1) { - this.formGroup.controls.email.setValue(qParamsEmail); - paramEmailIsSet = true; - } - }); - - // If there is no email in the query params, attempt to load email settings from loginEmailService - if (!paramEmailIsSet) { - await this.loadEmailSettings(); - } + await this.defaultOnInit(); if (this.clientType === ClientType.Web) { // If there's an existing org invite, use it to get the password policies @@ -362,6 +343,29 @@ export class LoginComponentV2 implements OnInit, OnDestroy { } } + private async defaultOnInit(): Promise { + let paramEmailIsSet = false; + + this.activatedRoute.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => { + if (!params) { + return; + } + + const qParamsEmail = params.email; + + // If there is an email in the query params, set that email as the form field value + if (qParamsEmail?.indexOf("@") > -1) { + this.formGroup.controls.email.setValue(qParamsEmail); + paramEmailIsSet = true; + } + }); + + // If there is no email in the query params, attempt to load email settings from loginEmailService + if (!paramEmailIsSet) { + await this.loadEmailSettings(); + } + } + private async webOnInit(): Promise { this.activatedRoute.queryParams.pipe(first(), takeUntil(this.destroy$)).subscribe((qParams) => { // If there is a parameter called 'org', set previousUrl to `/create-organization?org=`