diff --git a/server/controllers/transactionController.js b/server/controllers/transactionController.js index 2a7bfca..a2e68ec 100644 --- a/server/controllers/transactionController.js +++ b/server/controllers/transactionController.js @@ -6,13 +6,17 @@ import { Notification } from '../models'; * @param {object} req - express http request object * @param {object} res - express http response object * @param {Bool} history - optional arguement indicating user history + * @param {Bool} admin - optional arguement indicating admin status * @return {object} - express http response object */ -export default (req, res, history) => { +export default (req, res, history, admin) => { const options = { order: [['id', 'DESC']] }; if (history) { options.where = { username: req.user.username }; } + if (admin) { + delete options.where; + } Notification.findAll(options) .then(notifications => ( res.status(200).send({ diff --git a/server/routes/index.js b/server/routes/index.js index 12febd8..a37b2c7 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -76,7 +76,7 @@ router.get('/api/v1', (req, res) => res.status(200).send({ '/api/v1/admin-notifications', authenticate, ensureIsAdmin, - transactionController + (req, res) => transactionController(req, res, false, true) ) // Send a message if route does not exist .get('/api*', (req, res) => res.status(404).send({