From 84dc1d1b74ff24a088668c35fc7ec39f75d83282 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 13 Jul 2018 16:24:53 -0400 Subject: [PATCH] verify recovery delete page --- jslib | 2 +- .../verify-recover-delete.component.html | 26 ++++++++ .../verify-recover-delete.component.ts | 62 +++++++++++++++++++ src/app/app-routing.module.ts | 27 +++++++- src/app/app.module.ts | 2 + src/locales/en/messages.json | 3 + 6 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 src/app/accounts/verify-recover-delete.component.html create mode 100644 src/app/accounts/verify-recover-delete.component.ts diff --git a/jslib b/jslib index 9bc7459eac..51f041a959 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 9bc7459eacb55a234da8dd8aa71c059a4cd3e1ee +Subproject commit 51f041a9596168af0caa5ca94c0c1c6e7568f084 diff --git a/src/app/accounts/verify-recover-delete.component.html b/src/app/accounts/verify-recover-delete.component.html new file mode 100644 index 0000000000..826350057f --- /dev/null +++ b/src/app/accounts/verify-recover-delete.component.html @@ -0,0 +1,26 @@ +
+
+
+

{{'deleteAccount' | i18n}}

+
+
+ {{'deleteAccountWarning' | i18n}} +

+ {{email}} +

+

{{'deleteRecoverConfirmDesc' | i18n}}

+
+
+ + + {{'cancel' | i18n}} + +
+
+
+
+
+
diff --git a/src/app/accounts/verify-recover-delete.component.ts b/src/app/accounts/verify-recover-delete.component.ts new file mode 100644 index 0000000000..47bd507a90 --- /dev/null +++ b/src/app/accounts/verify-recover-delete.component.ts @@ -0,0 +1,62 @@ +import { + Component, + OnInit, +} from '@angular/core'; +import { + ActivatedRoute, + Router, +} from '@angular/router'; + +import { ToasterService } from 'angular2-toaster'; +import { Angulartics2 } from 'angulartics2'; + +import { ApiService } from 'jslib/abstractions/api.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; + +import { VerifyDeleteRecoverRequest } from 'jslib/models/request/verifyDeleteRecoverRequest'; + +@Component({ + selector: 'app-verify-recover-delete', + templateUrl: 'verify-recover-delete.component.html', +}) +export class VerifyRecoverDeleteComponent implements OnInit { + email: string; + formPromise: Promise; + + private userId: string; + private token: string; + + constructor(private router: Router, private apiService: ApiService, + private analytics: Angulartics2, private toasterService: ToasterService, + private i18nService: I18nService, private route: ActivatedRoute) { + } + + ngOnInit() { + let fired = false; + this.route.queryParams.subscribe(async (qParams) => { + if (fired) { + return; + } + fired = true; + if (qParams.userId != null && qParams.token != null && qParams.email != null) { + this.userId = qParams.userId; + this.token = qParams.token; + this.email = qParams.email; + } else { + this.router.navigate(['/']); + } + }); + } + + async submit() { + try { + const request = new VerifyDeleteRecoverRequest(this.userId, this.token); + this.formPromise = this.apiService.postAccountRecoverDeleteToken(request); + await this.formPromise; + this.analytics.eventTrack.next({ action: 'Recovered Delete' }); + this.toasterService.popAsync('success', this.i18nService.t('accountDeleted'), + this.i18nService.t('accountDeletedDesc')); + this.router.navigate(['/']); + } catch { } + } +} diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 91ef5dee53..c0d3a9a61d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -17,6 +17,7 @@ import { RecoverTwoFactorComponent } from './accounts/recover-two-factor.compone import { RegisterComponent } from './accounts/register.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { VerifyEmailTokenComponent } from './accounts/verify-email-token.component'; +import { VerifyRecoverDeleteComponent } from './accounts/verify-recover-delete.component'; import { CollectionsComponent as OrgManageCollectionsComponent } from './organizations/manage/collections.component'; import { EventsComponent as OrgEventsComponent } from './organizations/manage/events.component'; @@ -75,10 +76,30 @@ const routes: Routes = [ }, { path: 'lock', component: LockComponent }, { path: 'verify-email', component: VerifyEmailTokenComponent }, - { path: 'accept-organization', component: AcceptOrganizationComponent }, + { + path: 'accept-organization', + component: AcceptOrganizationComponent, + data: { titleId: 'joinOrganization' }, + }, { path: 'recover', pathMatch: 'full', redirectTo: 'recover-2fa' }, - { path: 'recover-2fa', component: RecoverTwoFactorComponent, canActivate: [UnauthGuardService] }, - { path: 'recover-delete', component: RecoverDeleteComponent, canActivate: [UnauthGuardService] }, + { + path: 'recover-2fa', + component: RecoverTwoFactorComponent, + canActivate: [UnauthGuardService], + data: { titleId: 'recoverAccountTwoStep' }, + }, + { + path: 'recover-delete', + component: RecoverDeleteComponent, + canActivate: [UnauthGuardService], + data: { titleId: 'deleteAccount' }, + }, + { + path: 'verify-recover-delete', + component: VerifyRecoverDeleteComponent, + canActivate: [UnauthGuardService], + data: { titleId: 'deleteAccount' }, + }, ], }, { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index aaf8b791ed..04462b2749 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -35,6 +35,7 @@ import { RegisterComponent } from './accounts/register.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { VerifyEmailTokenComponent } from './accounts/verify-email-token.component'; +import { VerifyRecoverDeleteComponent } from './accounts/verify-recover-delete.component'; import { CollectionAddEditComponent as OrgCollectionAddEditComponent, @@ -235,6 +236,7 @@ import { SearchPipe } from 'jslib/angular/pipes/search.pipe'; VaultComponent, VerifyEmailComponent, VerifyEmailTokenComponent, + VerifyRecoverDeleteComponent, ], entryComponents: [ AddEditComponent, diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index beeee3d554..47416835b4 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -2140,5 +2140,8 @@ }, "deleteRecoverEmailSent": { "message": "If your account exists, we've sent you an email with further instructions." + }, + "deleteRecoverConfirmDesc": { + "message": "You have requested to delete your Bitwarden account. Click the button below to confirm." } }