* Validates the user identified in the request session is a data admin. * Ends the request and returns an error if they are not. * @param {*} req The Express request object * @param {*} res The Express response object
(req, res)
| 69 | * @param {*} res The Express response object |
| 70 | */ |
| 71 | function checkDataAdmin(req, res) { |
| 72 | if (req.session && |
| 73 | (req.session.groups === undefined) || |
| 74 | ((req.session.groups.indexOf('admin') === -1) && |
| 75 | (req.session.groups.indexOf('data_admin') === -1))) { |
| 76 | res.status(401).json({ |
| 77 | 'message': 'You do not appear to have modify permissions', |
| 78 | }); |
| 79 | } else if (!req.session) { |
| 80 | res.status(401).json({ |
| 81 | 'message': 'You do not appear to have a session', |
| 82 | }); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Confirm that all parameters are a string and not an array. |