import { CanActivate, Router } from '@angular/router'; import { AuthService } from './auth.service'; import { Injectable } from '@angular/core'; @Injectable() export class AuthGuard implements CanActivate { constructor(private authService: AuthService, private router: Router) {} canActivate( route: import('@angular/router').ActivatedRouteSnapshot, state: import('@angular/router').RouterStateSnapshot ): | boolean | import('@angular/router').UrlTree | import('rxjs').Observable | Promise { const isAuth = this.authService.getIsAuthenticated(); if (!isAuth){ this.router.navigate['/auth/login'] } return isAuth } }