1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01:00

Auth/PM-11635 - Extension Registration Bugfix - Unable to login after account creation issue (#10896)

* PM-11635 - Refactor Base Login Component NgOnInit to properly connect the loading of email settings from state to the processing of query params. If an email is not passed via query params (like registration / normal login), then we will try to load the email from state.

* PM-11635 - Extension login component - call parent ngOnInit as it is responsible for processing / setting email from either query params or state. The addition of the child ngOnInit prevented the parent component ngOnInit from executing.
This commit is contained in:
Jared Snider 2024-09-05 13:55:30 -04:00 committed by GitHub
parent 0902ca5ae8
commit 352ab29665
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 16 deletions

View File

@ -86,10 +86,8 @@ export class LoginComponent extends BaseLoginComponent implements OnInit {
}
async ngOnInit(): Promise<void> {
await super.ngOnInit();
if (this.showPasswordless) {
const loginEmail = await firstValueFrom(this.loginEmailService.loginEmail$);
this.formGroup.controls.email.setValue(loginEmail);
this.formGroup.controls.rememberEmail.setValue(this.loginEmailService.getRememberEmail());
await this.validateEmail();
}
}

View File

@ -1,8 +1,8 @@
import { Directive, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { Subject, firstValueFrom } from "rxjs";
import { take, takeUntil } from "rxjs/operators";
import { Subject, firstValueFrom, of } from "rxjs";
import { switchMap, take, takeUntil } from "rxjs/operators";
import {
LoginStrategyServiceAbstraction,
@ -99,9 +99,12 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
}
async ngOnInit() {
this.route?.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
this.route?.queryParams
.pipe(
switchMap((params) => {
if (!params) {
return;
// If no params,loadEmailSettings from state
return this.loadEmailSettings();
}
const queryParamsEmail = params.email;
@ -110,9 +113,17 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
this.formGroup.controls.email.setValue(queryParamsEmail);
this.paramEmailSet = true;
}
});
if (!this.paramEmailSet) {
// If paramEmailSet is false, loadEmailSettings from state
return this.paramEmailSet ? of(null) : this.loadEmailSettings();
}),
takeUntil(this.destroy$),
)
.subscribe();
// Backup check to handle unknown case where activatedRoute is not available
// This shouldn't happen under normal circumstances
if (!this.route) {
await this.loadEmailSettings();
}
}