Skip to content

Commit b779909

Browse files
committed
chore: Improve comments for role-based access in employee routes
1 parent 898b382 commit b779909

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

routers/employees.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ const router = express.Router();
33
const employeeController = require('../controllers/employeeController');
44
const { 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)
710
router.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
2025
router.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
4047
router.delete('/:id',
4148
authenticateToken,
49+
// Deleting employees should typically be restricted to the highest level.
4250
authorizeRoles('Admin'),
4351
employeeController.deleteEmployee
4452
);

0 commit comments

Comments
 (0)