From 16450f3ba95250cd610f004b1d4fa3a12d3d4f9b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 31 Jan 2018 17:06:14 -0500 Subject: [PATCH] password hint page --- src/app/accounts/hint.component.html | 23 ++++++++++++ src/app/accounts/hint.component.ts | 48 ++++++++++++++++++++++++ src/app/accounts/login.component.html | 4 +- src/app/accounts/register.component.html | 2 +- src/app/app-routing.module.ts | 2 + src/app/app.module.ts | 2 + src/scss/pages.scss | 19 +++++----- 7 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 src/app/accounts/hint.component.html create mode 100644 src/app/accounts/hint.component.ts diff --git a/src/app/accounts/hint.component.html b/src/app/accounts/hint.component.html new file mode 100644 index 0000000000..a02749c609 --- /dev/null +++ b/src/app/accounts/hint.component.html @@ -0,0 +1,23 @@ +
+
+

{{'passwordHint' | i18n}}

+
+
+
+ + +
+
+ +
+
+ + {{'cancel' | i18n}} +
+
+
diff --git a/src/app/accounts/hint.component.ts b/src/app/accounts/hint.component.ts new file mode 100644 index 0000000000..023dc15fd8 --- /dev/null +++ b/src/app/accounts/hint.component.ts @@ -0,0 +1,48 @@ +import * as template from './hint.component.html'; + +import { + Component, +} from '@angular/core'; + +import { Router } from '@angular/router'; + +import { Angulartics2 } from 'angulartics2'; +import { ToasterService } from 'angular2-toaster'; + +import { PasswordHintRequest } from 'jslib/models/request/passwordHintRequest'; + +import { ApiService } from 'jslib/abstractions/api.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; + +@Component({ + selector: 'app-hint', + template: template, +}) +export class HintComponent { + email: string = ''; + formPromise: Promise; + + constructor(private router: Router, private analytics: Angulartics2, private toasterService: ToasterService, + private i18nService: I18nService, private apiService: ApiService) { } + + async submit() { + if (this.email == null || this.email === '') { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('emailRequired')); + return; + } + if (this.email.indexOf('@') === -1) { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('invalidEmail')); + return; + } + + try { + this.formPromise = this.apiService.postPasswordHint(new PasswordHintRequest(this.email)); + await this.formPromise; + this.analytics.eventTrack.next({ action: 'Requested Hint' }); + this.toasterService.popAsync('success', null, this.i18nService.t('masterPassSent')); + this.router.navigate(['login']); + } catch { } + } +} diff --git a/src/app/accounts/login.component.html b/src/app/accounts/login.component.html index 52fe05eb3f..a972c3a484 100644 --- a/src/app/accounts/login.component.html +++ b/src/app/accounts/login.component.html @@ -26,9 +26,9 @@ - +  {{'settings' | i18n}} diff --git a/src/app/accounts/register.component.html b/src/app/accounts/register.component.html index 7b84f34250..664a08b2d9 100644 --- a/src/app/accounts/register.component.html +++ b/src/app/accounts/register.component.html @@ -1,6 +1,6 @@
-

{{'createAccount' | i18n}}

+

{{'createAccount' | i18n}}

diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 25bb879908..070b339769 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,6 +4,7 @@ import { Routes, } from '@angular/router'; +import { HintComponent } from './accounts/hint.component'; import { LoginComponent } from './accounts/login.component'; import { RegisterComponent } from './accounts/register.component'; import { VaultComponent } from './vault/vault.component'; @@ -13,6 +14,7 @@ const routes: Routes = [ { path: 'login', component: LoginComponent }, { path: 'register', component: RegisterComponent }, { path: 'vault', component: VaultComponent }, + { path: 'hint', component: HintComponent }, ]; @NgModule({ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 11f8bcc1fe..51ba056c06 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import { CiphersComponent } from './vault/ciphers.component'; import { FallbackSrcDirective } from './directives/fallback-src.directive'; import { FolderAddEditComponent } from './vault/folder-add-edit.component'; import { GroupingsComponent } from './vault/groupings.component'; +import { HintComponent } from './accounts/hint.component'; import { I18nPipe } from './pipes/i18n.pipe'; import { IconComponent } from './vault/icon.component'; import { LoginComponent } from './accounts/login.component'; @@ -58,6 +59,7 @@ import { ViewComponent } from './vault/view.component'; FallbackSrcDirective, FolderAddEditComponent, GroupingsComponent, + HintComponent, I18nPipe, IconComponent, LoginComponent, diff --git a/src/scss/pages.scss b/src/scss/pages.scss index 8e1ccfd4fd..ea562c0508 100644 --- a/src/scss/pages.scss +++ b/src/scss/pages.scss @@ -15,9 +15,15 @@ height: calc(100% + 300px); margin-top: -300px; } + + img { + margin: 0 auto 15px; + width: 282px; + display: block; + } } -#register { +#register, #hint { margin-top: 20px; .content { @@ -25,20 +31,15 @@ } } -#login, #register { +#login, #register, #hint { .content { max-width: 300px; - img { - margin: 0 auto 15px; - width: 282px; - display: block; - } - - p { + p, h1 { font-size: $font-size-large; text-align: center; margin-bottom: 20px; + font-weight: normal; } .box {