import {inject} from '@angular/core'; import {CanActivateFn, Router} from '@angular/router'; import {AuthService} from '../services/auth'; export const adminAuthGuard: CanActivateFn = (route, state) => { const authService = inject(AuthService); const router = inject(Router); // Replace these with your actual authentication and role-checking methods const isAuthenticated = authService.isLoggedIn(); const isAdmin = authService.currentUserRole() === 'ADMIN'; if (isAuthenticated && isAdmin) { return true; } // Optional: Redirect to a generic 'unauthorized' page or back to the landing page/login console.warn('Access denied: Admin privileges required.'); return router.createUrlTree(['/login']); };