import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree, } from '@angular/router'; import { Observable } from 'rxjs'; import { UserType } from '../constants/user-type'; import { AuthService } from '../services/auth.service'; @Injectable({ providedIn: 'root', }) export class EmployeeGuard implements CanActivate { constructor(private auth: AuthService) {} canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { return this.auth.loggedInUserType === UserType.Employee; } }