mirror of
https://github.com/bitwarden/browser
synced 2024-12-12 01:08:06 +01:00
30 lines
871 B
TypeScript
30 lines
871 B
TypeScript
|
import { Injectable } from '@angular/core';
|
||
|
import {
|
||
|
CanActivate,
|
||
|
Router,
|
||
|
} from '@angular/router';
|
||
|
|
||
|
import { UserService } from '../../abstractions/user.service';
|
||
|
import { VaultTimeoutService } from '../../abstractions/vaultTimeout.service';
|
||
|
|
||
|
@Injectable()
|
||
|
export class UnauthGuardService implements CanActivate {
|
||
|
constructor(private vaultTimeoutService: VaultTimeoutService, private userService: UserService,
|
||
|
private router: Router) { }
|
||
|
|
||
|
async canActivate() {
|
||
|
const isAuthed = await this.userService.isAuthenticated();
|
||
|
if (isAuthed) {
|
||
|
const locked = await this.vaultTimeoutService.isLocked();
|
||
|
if (locked) {
|
||
|
this.router.navigate(['lock']);
|
||
|
} else {
|
||
|
this.router.navigate(['vault']);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|