Currently, I am facing a challenge while using Angular Guards to secure my pages from unauthorized access.
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot , Router } from '@angular/router';
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
{ AuthService } from './auth.service';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService,
private router: Router) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
if(this.authService.isAuth) {
return true;
} else {
this.router.navigate(['/login']);
}
}
}
I'm currently encountering an issue where I am unable to import the auth.service module. The error message displayed is 'cannot find module './auth.service'. Any suggestions on how to resolve this?