File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,14 @@ const router = express.Router();
33const employeeController = require ( '../controllers/employeeController' ) ;
44const { authenticateToken, authorizeRoles } = require ( '../middleware/auth' ) ;
55
6+ // Note: Ensure the roles used here ('Admin', 'Manager') match the exact case
7+ // stored in your database's user_account.role column.
8+
69// Get all employees (with optional filters)
710router . get ( '/' ,
8- authenticateToken ,
11+ authenticateToken ,
12+ // Required roles for viewing all employee data
13+ authorizeRoles ( 'Admin' , 'Manager' ) ,
914 employeeController . getAllEmployees
1015) ;
1116
@@ -19,6 +24,8 @@ router.get('/stats',
1924// Get single employee by ID
2025router . get ( '/:id' ,
2126 authenticateToken ,
27+ // Often, any employee or the employee themselves should be able to view their own profile.
28+ // Assuming general authenticated access is sufficient here, but Manager/Admin might be better.
2229 employeeController . getEmployeeById
2330) ;
2431
@@ -39,6 +46,7 @@ router.put('/:id',
3946// Delete employee
4047router . delete ( '/:id' ,
4148 authenticateToken ,
49+ // Deleting employees should typically be restricted to the highest level.
4250 authorizeRoles ( 'Admin' ) ,
4351 employeeController . deleteEmployee
4452) ;
You can’t perform that action at this time.
0 commit comments