From 1dc4f851cb7fbfdddf1e5a39d0babee7a11c531f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 12 Jul 2018 17:09:09 -0400 Subject: [PATCH] hasEncKey checks --- jslib | 2 +- src/app/settings/change-email.component.ts | 4 ++-- src/app/settings/change-password.component.ts | 4 ++-- src/app/vault/vault.component.ts | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/jslib b/jslib index 5fac067713..cc6f732a14 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 5fac06771310a083a004542db4c67028308f40c9 +Subproject commit cc6f732a140e5f49f0c2fe22c34da660ffe5ea89 diff --git a/src/app/settings/change-email.component.ts b/src/app/settings/change-email.component.ts index 21f2fc460b..f2db2cbe93 100644 --- a/src/app/settings/change-email.component.ts +++ b/src/app/settings/change-email.component.ts @@ -30,8 +30,8 @@ export class ChangeEmailComponent { private cryptoService: CryptoService, private messagingService: MessagingService) { } async submit() { - const hasKey = await this.cryptoService.hasKey(); - if (!hasKey) { + const hasEncKey = await this.cryptoService.hasEncKey(); + if (!hasEncKey) { this.toasterService.popAsync('error', null, this.i18nService.t('updateKey')); return; } diff --git a/src/app/settings/change-password.component.ts b/src/app/settings/change-password.component.ts index 61c108cda2..75ffcfda28 100644 --- a/src/app/settings/change-password.component.ts +++ b/src/app/settings/change-password.component.ts @@ -28,8 +28,8 @@ export class ChangePasswordComponent { private userService: UserService) { } async submit() { - const hasKey = await this.cryptoService.hasKey(); - if (!hasKey) { + const hasEncKey = await this.cryptoService.hasEncKey(); + if (!hasEncKey) { this.toasterService.popAsync('error', null, this.i18nService.t('updateKey')); return; } diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 18e4f991c7..e5296e5666 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -29,8 +29,8 @@ import { FolderAddEditComponent } from './folder-add-edit.component'; import { GroupingsComponent } from './groupings.component'; import { ShareComponent } from './share.component'; +import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; -import { StorageService } from 'jslib/abstractions/storage.service'; import { SyncService } from 'jslib/abstractions/sync.service'; import { TokenService } from 'jslib/abstractions/token.service'; @@ -64,12 +64,13 @@ export class VaultComponent implements OnInit { constructor(private syncService: SyncService, private route: ActivatedRoute, private router: Router, private location: Location, private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver, - private tokenService: TokenService, private storageService: StorageService) { } + private tokenService: TokenService, private cryptoService: CryptoService) { } async ngOnInit() { this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); this.showBrowserOutdated = window.navigator.userAgent.indexOf('MSIE') !== -1; - this.showUpdateKey = !this.showVerifyEmail && (await this.storageService.get('encKey')) == null; + const hasEncKey = await this.cryptoService.hasEncKey(); + this.showUpdateKey = !this.showVerifyEmail && hasEncKey; this.route.queryParams.subscribe(async (params) => { await this.syncService.fullSync(false);