diff --git a/client/admin/src/app/auth.guard.ts b/client/admin/src/app/auth.guard.ts index d45e6dc..f5065e2 100644 --- a/client/admin/src/app/auth.guard.ts +++ b/client/admin/src/app/auth.guard.ts @@ -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) { - return true; - } - - this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }}); +export const AuthGuard: CanActivateFn = (route, state) => { + if (sessionStorage.getItem('jwt') == null) { return false; + } else { + return true; } };