Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SG-753] Keep email after hint component is launched in browser #3883

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/browser/src/popup/accounts/hint.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise">
<header>
<div class="left">
<button type="button" routerLink="/login">{{ "cancel" | i18n }}</button>
<button type="button" routerLink="/login" [queryParams]="{ email: emailSent }">
{{ "cancel" | i18n }}
</button>
</div>
<h1 class="center">
<span class="title">{{ "passwordHint" | i18n }}</span>
Expand Down
32 changes: 28 additions & 4 deletions apps/browser/src/popup/accounts/hint.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from "@angular/core";
import { Router } from "@angular/router";
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { Subject, takeUntil } from "rxjs";

import { HintComponent as BaseHintComponent } from "@bitwarden/angular/components/hint.component";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
Expand All @@ -11,14 +12,37 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
selector: "app-hint",
templateUrl: "hint.component.html",
})
export class HintComponent extends BaseHintComponent {
export class HintComponent extends BaseHintComponent implements OnInit {
emailSent: string;
private destroy$ = new Subject<void>();

constructor(
router: Router,
platformUtilsService: PlatformUtilsService,
i18nService: I18nService,
apiService: ApiService,
logService: LogService
logService: LogService,
private route: ActivatedRoute
) {
super(router, i18nService, apiService, platformUtilsService, logService);

super.onSuccessfulSubmit = async () => {
this.router.navigate([this.successRoute], { queryParams: { email: this.emailSent } });
};
}
ngOnInit() {
this.route?.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
if (params) {
const queryParamsEmail = params["email"];
if (queryParamsEmail != null && queryParamsEmail.indexOf("@") > -1) {
this.emailSent = this.email = queryParamsEmail;
}
}
});
}

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
}
7 changes: 6 additions & 1 deletion apps/browser/src/popup/accounts/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ <h1 class="center">
</div>
</div>
<div class="box-footer">
<button type="button" class="btn link" routerLink="/hint">
<button
type="button"
class="btn link"
routerLink="/hint"
[queryParams]="{ email: loggedEmail }"
>
<b>{{ "getMasterPasswordHint" | i18n }}</b>
</button>
</div>
Expand Down