implement hasKey helper
This commit is contained in:
parent
e714d61a66
commit
94c5bdb5aa
|
@ -33,10 +33,9 @@ export class LockComponent extends BaseLockComponent implements OnInit {
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const authed = await this.userService.isAuthenticated();
|
const authed = await this.userService.isAuthenticated();
|
||||||
const key = await this.cryptoService.getKey();
|
|
||||||
if (!authed) {
|
if (!authed) {
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
} else if (key != null) {
|
} else if (await this.cryptoService.hasKey()) {
|
||||||
this.router.navigate(['vault']);
|
this.router.navigate(['vault']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ export class UnauthGuardService implements CanActivate {
|
||||||
async canActivate() {
|
async canActivate() {
|
||||||
const isAuthed = await this.userService.isAuthenticated();
|
const isAuthed = await this.userService.isAuthenticated();
|
||||||
if (isAuthed) {
|
if (isAuthed) {
|
||||||
const key = await this.cryptoService.getKey();
|
const hasKey = await this.cryptoService.hasKey();
|
||||||
if (key == null) {
|
if (!hasKey) {
|
||||||
this.router.navigate(['lock']);
|
this.router.navigate(['lock']);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['vault']);
|
this.router.navigate(['vault']);
|
||||||
|
|
Loading…
Reference in New Issue