import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; import { ApiAuthenticationService } from '../services/api/api-authentication.service'; @Injectable({ providedIn: 'root' }) export class AuthGuard implements CanActivate { constructor(private auth: ApiAuthenticationService, private router: Router) {} async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { if (this.auth.isAuthenticated()) { console.log('Valid OAuth'); return true; } console.log("Invalid OAuth"); return false; } }