From d9ff799681b3fc1b25202b949f181a3518577375 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 4 Apr 2018 23:01:40 -0400 Subject: [PATCH] move lock component to jslib --- jslib | 2 +- src/app/accounts/lock.component.ts | 52 ++++++------------------------ 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/jslib b/jslib index d429cd21..a0ca51dd 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d429cd2199e8a0880dfc0edbaea5fcad874eb424 +Subproject commit a0ca51dda4ebbf710284a0f4e59d47ac8f31c8e7 diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index d5e3dd87..e6d99ab8 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -12,52 +12,18 @@ import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { UserService } from 'jslib/abstractions/user.service'; +import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component'; + @Component({ selector: 'app-lock', template: template, }) -export class LockComponent { - masterPassword: string = ''; - showPassword: boolean = false; - - constructor(private router: Router, private analytics: Angulartics2, - private toasterService: ToasterService, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService, private messagingService: MessagingService, - private userService: UserService, private cryptoService: CryptoService) { } - - async submit() { - if (this.masterPassword == null || this.masterPassword === '') { - this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), - this.i18nService.t('masterPassRequired')); - return; - } - - const email = await this.userService.getEmail(); - const key = this.cryptoService.makeKey(this.masterPassword, email); - const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key); - const storedKeyHash = await this.cryptoService.getKeyHash(); - - if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) { - await this.cryptoService.setKey(key); - this.messagingService.send('unlocked'); - this.router.navigate(['vault']); - } else { - this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), - this.i18nService.t('invalidMasterPassword')); - } - } - - async logOut() { - const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('logOutConfirmation'), - this.i18nService.t('logOut'), this.i18nService.t('logOut'), this.i18nService.t('cancel')); - if (confirmed) { - this.messagingService.send('logout'); - } - } - - togglePassword() { - this.analytics.eventTrack.next({ action: 'Toggled Master Password on Unlock' }); - this.showPassword = !this.showPassword; - document.getElementById('masterPassword').focus(); +export class LockComponent extends BaseLockComponent { + constructor(router: Router, analytics: Angulartics2, + toasterService: ToasterService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, messagingService: MessagingService, + userService: UserService, cryptoService: CryptoService) { + super(router, analytics, toasterService, i18nService, platformUtilsService, + messagingService, userService, cryptoService); } }