implement hasKey helper

This commit is contained in:
Kyle Spearrin 2018-06-13 17:21:27 -04:00
parent e714d61a66
commit 94c5bdb5aa
2 changed files with 3 additions and 4 deletions

View File

@ -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']);
}

View File

@ -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']);