mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
updated the way privileges were handled in the .get() category controller
This commit is contained in:
@@ -38,7 +38,7 @@ categoriesController.popular = function(req, res, next) {
|
||||
|
||||
categoriesController.unread = function(req, res, next) {
|
||||
var uid = req.user.uid;
|
||||
|
||||
|
||||
topics.getUnreadTopics(uid, 0, 19, function (err, data) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
@@ -50,7 +50,7 @@ categoriesController.unread = function(req, res, next) {
|
||||
|
||||
categoriesController.unreadTotal = function(req, res, next) {
|
||||
var uid = req.user.uid;
|
||||
|
||||
|
||||
topics.getTotalUnread(uid, function (err, data) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
@@ -63,8 +63,7 @@ categoriesController.unreadTotal = function(req, res, next) {
|
||||
categoriesController.get = function(req, res, next) {
|
||||
var cid = req.params.category_id,
|
||||
page = req.query.page || 1,
|
||||
uid = req.user ? req.user.uid : 0,
|
||||
privileges = null;
|
||||
uid = req.user ? req.user.uid : 0;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -73,15 +72,14 @@ categoriesController.get = function(req, res, next) {
|
||||
if (!categoryPrivileges.read) {
|
||||
next(new Error('not-enough-privileges'));
|
||||
} else {
|
||||
privileges = categoryPrivileges;
|
||||
next();
|
||||
next(null, categoryPrivileges);
|
||||
}
|
||||
} else {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
function (privileges, next) {
|
||||
user.getSettings(uid, function(err, settings) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -97,6 +95,7 @@ categoriesController.get = function(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
categoryData.privileges = privileges;
|
||||
next(err, categoryData);
|
||||
});
|
||||
});
|
||||
@@ -132,7 +131,7 @@ categoriesController.get = function(req, res, next) {
|
||||
href: nconf.get('url')
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
next(null, categoryData);
|
||||
}
|
||||
], function (err, data) {
|
||||
@@ -154,7 +153,6 @@ categoriesController.get = function(req, res, next) {
|
||||
category_url += '?' + queryString;
|
||||
}
|
||||
|
||||
data.privileges = privileges;
|
||||
data.currentPage = page;
|
||||
|
||||
// Paginator for noscript
|
||||
|
||||
Reference in New Issue
Block a user