fix: #10906, allow `middleware.checkAccountPermissions` to be called with either uid or userslug in params

Previously, the middleware only worked with userslug params
isekai-main
Julian Lam 2 years ago
parent b5dd89e1c0
commit cf4f5447bb

@ -165,7 +165,11 @@ module.exports = function (middleware) {
return controllers.helpers.notAllowed(req, res);
}
const uid = await user.getUidByUserslug(req.params.userslug);
if (!['uid', 'userslug'].some(param => req.params.hasOwnProperty(param))) {
return controllers.helpers.notAllowed(req, res);
}
const uid = req.params.uid || await user.getUidByUserslug(req.params.userslug);
let allowed = await privileges.users.canEdit(req.uid, uid);
if (allowed) {
return next();

Loading…
Cancel
Save