hasEnoughRep can take an array

user follow uid checks
This commit is contained in:
barisusakli
2014-11-04 18:44:04 -05:00
parent 9a8fa35d8d
commit 37d7756271
3 changed files with 34 additions and 16 deletions

View File

@@ -123,7 +123,7 @@ function isGuestAllowedTo(privilege, cids, callback) {
}
helpers.hasEnoughReputationFor = function(privilege, uid, callback) {
if (parseInt(meta.config['privileges:disabled'], 10)) {
if (parseInt(meta.config['privileges:disabled'], 10) || !parseInt(uid, 10)) {
return callback(null, false);
}
@@ -131,7 +131,18 @@ helpers.hasEnoughReputationFor = function(privilege, uid, callback) {
if (err) {
return callback(null, false);
}
callback(null, parseInt(reputation, 10) >= parseInt(meta.config[privilege], 10));
reputation = parseInt(reputation, 10);
if (Array.isArray(privilege)) {
for(var i=0; i<privilege.length; ++i) {
if (reputation >= parseInt(meta.config[privilege[i]], 10)) {
return callback(null, true);
}
}
} else {
callback(null, reputation >= parseInt(meta.config[privilege], 10));
}
});
};