import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; import { AuthenticationService } from '../services/authentication.service'; import { GrpcAuthService } from '../services/grpc-auth.service'; @Injectable({ providedIn: 'root', }) export class AuthGuard implements CanActivate { constructor(private auth: AuthenticationService, private authService: GrpcAuthService) { } public canActivate( _: ActivatedRouteSnapshot, state: RouterStateSnapshot, ): Observable | Promise | Promise | boolean { if (!this.auth.authenticated) { return this.auth.authenticate(); } return this.auth.authenticated; } }