From b91054efe8e411d418c343a352354f195d7e0284 Mon Sep 17 00:00:00 2001 From: Segun Ola Date: Wed, 18 Oct 2017 05:42:02 +0100 Subject: [PATCH] Bug(hotfix): fix admin notification. Context: Notifications displayed were only for admin user --- server/controllers/transactionController.js | 6 +++++- server/routes/index.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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({