From 94c5bdb5aae8993749ff7e596e756c718c8fd57e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 13 Jun 2018 17:21:27 -0400 Subject: [PATCH] implement hasKey helper --- src/app/accounts/lock.component.ts | 3 +-- src/app/services/unauth-guard.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index c5daf754b5..70cec1bec6 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -33,10 +33,9 @@ export class LockComponent extends BaseLockComponent implements OnInit { async ngOnInit() { const authed = await this.userService.isAuthenticated(); - const key = await this.cryptoService.getKey(); if (!authed) { this.router.navigate(['/']); - } else if (key != null) { + } else if (await this.cryptoService.hasKey()) { this.router.navigate(['vault']); } diff --git a/src/app/services/unauth-guard.service.ts b/src/app/services/unauth-guard.service.ts index 3c89f26d4a..3b86cd6042 100644 --- a/src/app/services/unauth-guard.service.ts +++ b/src/app/services/unauth-guard.service.ts @@ -15,8 +15,8 @@ export class UnauthGuardService implements CanActivate { async canActivate() { const isAuthed = await this.userService.isAuthenticated(); if (isAuthed) { - const key = await this.cryptoService.getKey(); - if (key == null) { + const hasKey = await this.cryptoService.hasKey(); + if (!hasKey) { this.router.navigate(['lock']); } else { this.router.navigate(['vault']);