rollback guard
This commit is contained in:
parent
81aa96a77b
commit
ee7a44cd4b
1 changed files with 5 additions and 10 deletions
|
@ -1,14 +1,9 @@
|
|||
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { CanActivateFn } from '@angular/router';
|
||||
|
||||
export class AuthGuard implements CanActivate {
|
||||
constructor(private router: Router) { }
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
if (sessionStorage.getItem('jwt') != null) {
|
||||
export const AuthGuard: CanActivateFn = (route, state) => {
|
||||
if (sessionStorage.getItem('jwt') == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue