import { Injectable } from '@angular/core'; import { CanActivate, Router } from '@angular/router'; import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root', }) export class AuthGuard implements CanActivate { constructor(private auth: AuthService, private router: Router) { } canActivate(): boolean { if (this.auth.isAuthenticated) { return true; } else { // Redirect to signin and show modal this.router.navigate(['/'], { queryParams: { showSignIn: true } }); return false; } } }