From 1b63a8392671ae47e6ec22ad272ac839c65d4834 Mon Sep 17 00:00:00 2001 From: robdy <15113729+robdy@users.noreply.github.com> Date: Mon, 18 Jun 2018 10:58:22 +0200 Subject: [PATCH] Allow Post Mods to view mod notes (#628) --- api/policies/isPostMod.js | 1 + api/services/Users.js | 2 +- assets/views/home/modEdit.ejs | 6 +++--- assets/views/home/reference.ejs | 4 ++-- config/policies.js | 6 ++++++ 5 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 api/policies/isPostMod.js diff --git a/api/policies/isPostMod.js b/api/policies/isPostMod.js new file mode 100644 index 00000000..4058247e --- /dev/null +++ b/api/policies/isPostMod.js @@ -0,0 +1 @@ +module.exports = (req, res, next) => (Users.hasModPermission(req.user, 'posts') && Users.hasModPermission(req.user, 'wiki')) ? next() : res.forbidden("Not post mod"); diff --git a/api/services/Users.js b/api/services/Users.js index 552122fe..ed8416e8 100644 --- a/api/services/Users.js +++ b/api/services/Users.js @@ -28,7 +28,7 @@ exports.get = async function (requester, username) { user.comments = result; })); - if (Users.hasModPermission(requester, 'access')) { + if (Users.hasModPermission(requester, 'posts') && Users.hasModPermission(requester, 'wiki')) { promises.push(ModNote.find({refUser: user.name}).sort({createdAt: 'desc'}).then(function (result) { user.modNotes = result; })); diff --git a/assets/views/home/modEdit.ejs b/assets/views/home/modEdit.ejs index d673ee91..3214be8d 100644 --- a/assets/views/home/modEdit.ejs +++ b/assets/views/home/modEdit.ejs @@ -17,7 +17,7 @@ {{note.user}} {{note.createdAt | date: "medium"}} - + @@ -27,7 +27,7 @@ -