1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

Refactor canactivate guards (#401)

* Refactor route guards to allow for subclassing

* fix linting
This commit is contained in:
Thomas Rittson 2021-06-08 14:35:03 -07:00 committed by GitHub
parent ea90aea013
commit fdc6f7b1d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,8 @@ import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.serv
@Injectable()
export class LockGuardService implements CanActivate {
protected homepage = 'vault';
constructor(private vaultTimeoutService: VaultTimeoutService, private userService: UserService,
private router: Router) { }
@ -19,7 +21,7 @@ export class LockGuardService implements CanActivate {
if (locked) {
return true;
} else {
this.router.navigate(['vault']);
this.router.navigate([this.homepage]);
return false;
}
}

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivate,
Router,
} from '@angular/router';
@ -9,6 +10,8 @@ import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.serv
@Injectable()
export class UnauthGuardService implements CanActivate {
protected homepage = 'vault';
constructor(private vaultTimeoutService: VaultTimeoutService, private userService: UserService,
private router: Router) { }
@ -19,7 +22,7 @@ export class UnauthGuardService implements CanActivate {
if (locked) {
this.router.navigate(['lock']);
} else {
this.router.navigate(['vault']);
this.router.navigate([this.homepage]);
}
return false;
}