mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
closes #3631
This commit is contained in:
@@ -266,6 +266,21 @@ categoriesController.get = function(req, res, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
categoriesController.getCategory = function(req, res, next) {
|
||||
async.parallel({
|
||||
canRead: async.apply(privileges.categories.can, 'read', req.params.cid, req.uid),
|
||||
categoryData: async.apply(categories.getCategoryData, req.params.cid)
|
||||
}, function(err, results) {
|
||||
if (err || !results.categoryData) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!results.canRead) {
|
||||
return helpers.notAllowed(req, res);
|
||||
}
|
||||
|
||||
res.json(results.categoryData);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = categoriesController;
|
||||
|
||||
@@ -313,4 +313,21 @@ topicsController.teaser = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
topicsController.getTopic = function(req, res, next) {
|
||||
async.parallel({
|
||||
canRead: async.apply(privileges.topics.can, 'read', req.params.tid, req.uid),
|
||||
topicData: async.apply(topics.getTopicData, req.params.tid)
|
||||
}, function(err, results) {
|
||||
if (err || !results.topicData) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!results.canRead) {
|
||||
return helpers.notAllowed(req, res);
|
||||
}
|
||||
|
||||
res.json(results.topicData);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = topicsController;
|
||||
|
||||
@@ -15,7 +15,10 @@ module.exports = function(app, middleware, controllers) {
|
||||
router.get('/widgets/render', controllers.api.renderWidgets);
|
||||
|
||||
router.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);
|
||||
router.get('/post/:pid', controllers.posts.getPost);
|
||||
router.get('/post/pid/:pid', controllers.posts.getPost);
|
||||
router.get('/topic/tid/:tid', controllers.topics.getTopic);
|
||||
router.get('/category/cid/:cid', controllers.categories.getCategory);
|
||||
|
||||
router.get('/categories/:cid/moderators', getModerators);
|
||||
router.get('/recent/posts/:term?', getRecentPosts);
|
||||
router.get('/unread/total', middleware.authenticate, controllers.unread.unreadTotal);
|
||||
|
||||
Reference in New Issue
Block a user