mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
PM-1943 Migrate Recover Delete Component (#9169)
* PM-1943 Migrate Recover Delete Component * PM-1943 Anon layout changes done * PM-1943 - await navigate * PM-1943 - Add new anon layout wrapper env selector. --------- Co-authored-by: Jared Snider <jsnider@bitwarden.com>
This commit is contained in:
committed by
GitHub
parent
88dc574982
commit
d5e0ab74a4
@@ -1,44 +1,16 @@
|
|||||||
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" class="container" ngNativeValidate>
|
<form [formGroup]="recoverDeleteForm" [bitSubmit]="submit">
|
||||||
<div class="row justify-content-md-center mt-5">
|
<p bitTypography="body1">{{ "deleteRecoverDesc" | i18n }}</p>
|
||||||
<div class="col-5">
|
<bit-form-field>
|
||||||
<p class="lead text-center mb-4">{{ "deleteAccount" | i18n }}</p>
|
<bit-label>{{ "emailAddress" | i18n }}</bit-label>
|
||||||
<div class="card">
|
<input bitInput appAutofocus appInputVerbatim="false" type="email" formControlName="email" />
|
||||||
<div class="card-body">
|
</bit-form-field>
|
||||||
<p>{{ "deleteRecoverDesc" | i18n }}</p>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">{{ "emailAddress" | i18n }}</label>
|
|
||||||
<input
|
|
||||||
id="email"
|
|
||||||
class="form-control"
|
|
||||||
type="text"
|
|
||||||
name="Email"
|
|
||||||
[(ngModel)]="email"
|
|
||||||
required
|
|
||||||
appAutofocus
|
|
||||||
inputmode="email"
|
|
||||||
appInputVerbatim="false"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<hr />
|
<hr />
|
||||||
<div class="d-flex">
|
<div class="tw-flex tw-gap-2">
|
||||||
<button
|
<button type="submit" bitButton bitFormButton buttonType="primary" [block]="true">
|
||||||
type="submit"
|
{{ "submit" | i18n }}
|
||||||
class="btn btn-primary btn-block btn-submit"
|
|
||||||
[disabled]="form.loading"
|
|
||||||
>
|
|
||||||
<span>{{ "submit" | i18n }}</span>
|
|
||||||
<i
|
|
||||||
class="bwi bwi-spinner bwi-spin"
|
|
||||||
title="{{ 'loading' | i18n }}"
|
|
||||||
aria-hidden="true"
|
|
||||||
></i>
|
|
||||||
</button>
|
</button>
|
||||||
<a routerLink="/login" class="btn btn-outline-secondary btn-block ml-2 mt-0">
|
<a bitButton buttonType="secondary" routerLink="/login" [block]="true">
|
||||||
{{ "cancel" | i18n }}
|
{{ "cancel" | i18n }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { DeleteRecoverRequest } from "@bitwarden/common/models/request/delete-recover.request";
|
import { DeleteRecoverRequest } from "@bitwarden/common/models/request/delete-recover.request";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -12,33 +12,27 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
templateUrl: "recover-delete.component.html",
|
templateUrl: "recover-delete.component.html",
|
||||||
})
|
})
|
||||||
export class RecoverDeleteComponent {
|
export class RecoverDeleteComponent {
|
||||||
email: string;
|
protected recoverDeleteForm = new FormGroup({
|
||||||
formPromise: Promise<any>;
|
email: new FormControl(null, [Validators.required]),
|
||||||
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private logService: LogService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async submit() {
|
submit = async () => {
|
||||||
try {
|
|
||||||
const request = new DeleteRecoverRequest();
|
const request = new DeleteRecoverRequest();
|
||||||
request.email = this.email.trim().toLowerCase();
|
request.email = this.recoverDeleteForm.value.email.trim().toLowerCase();
|
||||||
this.formPromise = this.apiService.postAccountRecoverDelete(request);
|
await this.apiService.postAccountRecoverDelete(request);
|
||||||
await this.formPromise;
|
|
||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"success",
|
"success",
|
||||||
null,
|
null,
|
||||||
this.i18nService.t("deleteRecoverEmailSent"),
|
this.i18nService.t("deleteRecoverEmailSent"),
|
||||||
);
|
);
|
||||||
// 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
|
await this.router.navigate(["/"]);
|
||||||
this.router.navigate(["/"]);
|
};
|
||||||
} catch (e) {
|
|
||||||
this.logService.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,12 +134,6 @@ const routes: Routes = [
|
|||||||
data: { titleId: "acceptFamilySponsorship", doNotSaveUrl: false } satisfies DataProperties,
|
data: { titleId: "acceptFamilySponsorship", doNotSaveUrl: false } satisfies DataProperties,
|
||||||
},
|
},
|
||||||
{ path: "recover", pathMatch: "full", redirectTo: "recover-2fa" },
|
{ path: "recover", pathMatch: "full", redirectTo: "recover-2fa" },
|
||||||
{
|
|
||||||
path: "recover-delete",
|
|
||||||
component: RecoverDeleteComponent,
|
|
||||||
canActivate: [UnauthGuard],
|
|
||||||
data: { titleId: "deleteAccount" } satisfies DataProperties,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "verify-recover-delete",
|
path: "verify-recover-delete",
|
||||||
component: VerifyRecoverDeleteComponent,
|
component: VerifyRecoverDeleteComponent,
|
||||||
@@ -231,6 +225,20 @@ const routes: Routes = [
|
|||||||
(mod) => mod.AcceptEmergencyComponent,
|
(mod) => mod.AcceptEmergencyComponent,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "recover-delete",
|
||||||
|
canActivate: [unauthGuardFn()],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
component: RecoverDeleteComponent,
|
||||||
|
data: {
|
||||||
|
pageTitle: "deleteAccount",
|
||||||
|
titleId: "deleteAccount",
|
||||||
|
} satisfies DataProperties & AnonLayoutWrapperData,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "",
|
path: "",
|
||||||
component: EnvironmentSelectorComponent,
|
component: EnvironmentSelectorComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user