1
0
mirror of https://github.com/bitwarden/web synced 2025-12-15 15:53:18 +00:00

auth guards

This commit is contained in:
Kyle Spearrin
2018-06-09 22:02:45 -04:00
parent 9f1c7a0a32
commit 7ebd18b00d
8 changed files with 67 additions and 19 deletions

View File

@@ -1,4 +1,7 @@
import { Component } from '@angular/core';
import {
Component,
OnInit,
} from '@angular/core';
import { Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster';
@@ -16,7 +19,7 @@ import { LockComponent as BaseLockComponent } from 'jslib/angular/components/loc
selector: 'app-lock',
templateUrl: 'lock.component.html',
})
export class LockComponent extends BaseLockComponent {
export class LockComponent extends BaseLockComponent implements OnInit {
constructor(router: Router, analytics: Angulartics2,
toasterService: ToasterService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
@@ -24,4 +27,14 @@ export class LockComponent extends BaseLockComponent {
super(router, analytics, toasterService, i18nService, platformUtilsService,
messagingService, userService, cryptoService);
}
async ngOnInit() {
const authed = await this.userService.isAuthenticated();
const key = await this.cryptoService.getKey();
if (!authed) {
this.router.navigate(['/']);
} else if (key != null) {
this.router.navigate(['vault']);
}
}
}