🔒️ Added admin guard (like an auth guard for real) to redirect user if not logged in

master
Alix JEUDI--LEMOINE 1 week ago
parent b02aa51bed
commit 9e1b0080ab

@ -0,0 +1,14 @@
import { inject } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../services/auth.service';
export const AdminGuard = () => {
const authService = inject(AuthService);
const router = inject(Router);
if (authService.isAdmin()) {
return true;
}
return router.parseUrl('/login');
};
Loading…
Cancel
Save