* Validates the user identified in the request session is an admin. * Ends the request and returns an error if they are not. * @param {Object} req The Express request object * @param {Object} res The Express response object
(req, res)
| 50 | * @param {Object} res The Express response object |
| 51 | */ |
| 52 | function checkAdmin(req, res) { |
| 53 | if (req.session && ((req.session.groups === undefined) || |
| 54 | (req.session.groups.indexOf('admin') === -1))) { |
| 55 | res.status(401).json({ |
| 56 | 'message': 'You do not appear to be an admin', |
| 57 | }); |
| 58 | } else if (!req.session) { |
| 59 | res.status(401).json({ |
| 60 | 'message': 'You do not appear to have a session', |
| 61 | }); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Validates the user identified in the request session is a data admin. |