import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree, } from '@angular/router'; import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root', }) export class IdentityAuthGuard implements CanActivate { constructor(private authService: AuthService) {} async canActivate(): Promise { console.log('hitting the guard'); const isLoggedIn = await this.authService.isUserLoggedIn(); if (isLoggedIn) { console.log('user approved'); return true; } else { console.log('user not approved'); return false; } } }