Skip to content

Commit

Permalink
Add _req_user to removed item so you can use this in the remove pre/p…
Browse files Browse the repository at this point in the history
…ost hook

As discussed in keystonejs/keystone#1857 the remove pre/post hooks are "missing" the _req_user. I, amongst others, am using this object to handle some permissions. It's available in the updateHandler (in `create` and `update`) but missing in `remove`.

it's added on the updateHandler here: https://github.com/keystonejs/keystone/blob/d34f45662eb359e2cb18b397f2ffea21f9883141/lib/list/updateItem.js#L157

Remove doesn't use the updateHandler, so this is missing.
  • Loading branch information
laurenskling authored Oct 12, 2018
1 parent 02accc6 commit 82a66d5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions admin/server/api/list/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = function (req, res) {
return res.apiError('database error', err);
}
async.forEachLimit(results, 10, function (item, next) {
item._req_user = req.user;
item.remove(function (err) {
if (err) return next(err);
deletedCount++;
Expand Down

0 comments on commit 82a66d5

Please sign in to comment.