Spaces:
Running
Running
feat: implement core backend POS API with authentication, role-based access control, menu management, and order processing logic.
1e480b5 Download src/middleware/roleGuard.js from aliroohan179/face: direct link, hf CLI and curl.
- Browser
- Download file 466 Bytes
-
https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/middleware/roleGuard.js
- Command line
-
hf download hf://spaces/aliroohan179/face/src/middleware/roleGuard.js
-
curl -L -o roleGuard.js https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/middleware/roleGuard.js
466 Bytes
| /** | |
| * Role guard factory. | |
| * Usage: requireRole('owner') or requireRole('owner', 'cashier') | |
| */ | |
| const requireRole = (...roles) => { | |
| return (req, res, next) => { | |
| if (!req.user) { | |
| return res.status(401).json({ message: 'Not authenticated' }); | |
| } | |
| if (!roles.includes(req.user.role)) { | |
| return res.status(403).json({ message: `Access denied. Required role: ${roles.join(' or ')}` }); | |
| } | |
| next(); | |
| }; | |
| }; | |
| module.exports = { requireRole }; | |