handling case where user does not satisfy any of the privilege thresholds given to the hasEnoughReputationFor method

v1.18.x
Julian Lam 10 years ago
parent 06f66337fb
commit 44175188c4

@ -40,7 +40,6 @@ topicsController.get = function(req, res, next) {
}, next); }, next);
}, },
function (results, next) { function (results, next) {
userPrivileges = results.privileges; userPrivileges = results.privileges;
if (userPrivileges.disabled) { if (userPrivileges.disabled) {

@ -140,6 +140,9 @@ helpers.hasEnoughReputationFor = function(privilege, uid, callback) {
return callback(null, true); return callback(null, true);
} }
} }
// Does not satisfy any of those thresholds?
return callback(null, false);
} else { } else {
callback(null, reputation >= parseInt(meta.config[privilege], 10)); callback(null, reputation >= parseInt(meta.config[privilege], 10));
} }

@ -265,6 +265,7 @@ var async = require('async'),
} }
pids = topicData.mainPid ? [topicData.mainPid].concat(pids) : pids; pids = topicData.mainPid ? [topicData.mainPid].concat(pids) : pids;
if (!pids.length) { if (!pids.length) {
return next(null, []); return next(null, []);
} }
@ -277,18 +278,10 @@ var async = require('async'),
}); });
}); });
}, },
category: function(next) { category: async.apply(Topics.getCategoryData, tid),
Topics.getCategoryData(tid, next); threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', []),
}, tags: async.apply(Topics.getTopicTagsObjects, tid),
threadTools: function(next) { isFollowing: async.apply(Topics.isFollowing, tid, uid)
plugins.fireHook('filter:topic.thread_tools', [], next);
},
tags: function(next) {
Topics.getTopicTagsObjects(tid, next);
},
isFollowing: function(next) {
Topics.isFollowing(tid, uid, next);
}
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);

Loading…
Cancel
Save