mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
adde expose methods back
used by plugins
This commit is contained in:
@@ -112,6 +112,28 @@ middleware.privateTagListing = function(req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
middleware.exposeGroupName = function(req, res, next) {
|
||||
expose('groupName', groups.getGroupNameByGroupSlug, 'slug', req, res, next);
|
||||
};
|
||||
|
||||
middleware.exposeUid = function(req, res, next) {
|
||||
expose('uid', user.getUidByUserslug, 'userslug', req, res, next);
|
||||
};
|
||||
|
||||
function expose(exposedField, method, field, req, res, next) {
|
||||
if (!req.params.hasOwnProperty(field)) {
|
||||
return next();
|
||||
}
|
||||
method(req.params[field], function(err, id) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.locals[exposedField] = id;
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
middleware.privateUploads = function(req, res, next) {
|
||||
if (req.user || parseInt(meta.config.privateUploads, 10) !== 1) {
|
||||
return next();
|
||||
|
||||
Reference in New Issue
Block a user