removing allowGuestPosting logic in NodeBB

v1.18.x
Julian Lam 12 years ago
parent 3474cdc5ea
commit b1534b7798

@ -11,10 +11,6 @@
"field": "minimumPostLength", "field": "minimumPostLength",
"value": 8 "value": 8
}, },
{
"field": "allowGuestPosting",
"value": 0
},
{ {
"field": "allowGuestSearching", "field": "allowGuestSearching",
"value": 0 "value": 0

@ -41,22 +41,22 @@ define(['taskbar'], function(taskbar) {
$el.unwrap(); $el.unwrap();
} }
function allowed() { // function allowed() {
if(!(parseInt(app.uid, 10) > 0 || config.allowGuestPosting)) { // if(!(parseInt(app.uid, 10) > 0 || config.allowGuestPosting)) {
app.alert({ // app.alert({
type: 'danger', // type: 'danger',
timeout: 5000, // timeout: 5000,
alert_id: 'post_error', // alert_id: 'post_error',
title: '[[global:please_log_in]]', // title: '[[global:please_log_in]]',
message: '[[global:posting_restriction_info]]', // message: '[[global:posting_restriction_info]]',
clickfn: function() { // clickfn: function() {
ajaxify.go('login'); // ajaxify.go('login');
} // }
}); // });
return false; // return false;
} // }
return true; // return true;
} // }
function alreadyOpen(post) { function alreadyOpen(post) {
// If a composer for the same cid/tid/pid is already open, return the uuid, else return bool false // If a composer for the same cid/tid/pid is already open, return the uuid, else return bool false
@ -484,9 +484,9 @@ define(['taskbar'], function(taskbar) {
}; };
composer.newTopic = function(cid) { composer.newTopic = function(cid) {
if(!allowed()) { // if(!allowed()) {
return; // return;
} // }
push({ push({
cid: cid, cid: cid,
@ -498,9 +498,9 @@ define(['taskbar'], function(taskbar) {
}; };
composer.addQuote = function(tid, pid, title, username, text){ composer.addQuote = function(tid, pid, title, username, text){
if (!allowed()) { // if (!allowed()) {
return; // return;
} // }
var uuid = composer.active; var uuid = composer.active;
@ -521,9 +521,9 @@ define(['taskbar'], function(taskbar) {
}; };
composer.newReply = function(tid, pid, title, text) { composer.newReply = function(tid, pid, title, text) {
if(!allowed()) { // if(!allowed()) {
return; // return;
} // }
push({ push({
tid: tid, tid: tid,
@ -536,9 +536,9 @@ define(['taskbar'], function(taskbar) {
}; };
composer.editPost = function(pid) { composer.editPost = function(pid) {
if(!allowed()) { // if(!allowed()) {
return; // return;
} // }
socket.emit('modules.composer.push', pid, function(err, threadData) { socket.emit('modules.composer.push', pid, function(err, threadData) {
if(err) { if(err) {
@ -610,7 +610,7 @@ define(['taskbar'], function(taskbar) {
thumbToggleBtnEl.removeClass('hide'); thumbToggleBtnEl.removeClass('hide');
} }
}; };
postData.title = $('<div></div>').html(postData.title).text(); postData.title = $('<div></div>').html(postData.title).text();
if (parseInt(postData.tid, 10) > 0) { if (parseInt(postData.tid, 10) > 0) {

@ -24,8 +24,7 @@ apiController.getConfig = function(req, res, next) {
config.minimumPasswordLength = meta.config.minimumPasswordLength; config.minimumPasswordLength = meta.config.minimumPasswordLength;
config.maximumSignatureLength = meta.config.maximumSignatureLength; config.maximumSignatureLength = meta.config.maximumSignatureLength;
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1; config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
config.allowGuestPosting = parseInt(meta.config.allowGuestPosting, 10) === 1; config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1;
config.allowGuestSearching = parseInt(meta.config.allowGuestPosting, 10) === 1;
config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1; config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1;
config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 10) === 1; config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 10) === 1;
config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1; config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1;

@ -38,6 +38,16 @@
}); });
} }
}); });
},
removeEphemeralGroups: function(groups) {
var x = groups.length;
while(x--) {
if (ephemeralGroups.indexOf(groups[x]) !== -1) {
groups.splice(x, 1);
}
}
return groups;
} }
}; };
@ -137,9 +147,14 @@
}; };
Groups.isMemberOfGroupList = function(uid, groupListKey, callback) { Groups.isMemberOfGroupList = function(uid, groupListKey, callback) {
db.getSetMembers('group:' + groupListKey + ':members', function(err, gids) { db.getSetMembers('group:' + groupListKey + ':members', function(err, groupNames) {
async.some(gids, function(gid, next) { groupNames = internals.removeEphemeralGroups(groupNames);
Groups.isMember(uid, gid, function(err, isMember) { if (groupNames.length === 0) {
return callback(null, null);
}
async.some(groupNames, function(groupName, next) {
Groups.isMember(uid, groupName, function(err, isMember) {
if (!err && isMember) { if (!err && isMember) {
next(true); next(true);
} else { } else {

@ -40,11 +40,11 @@ helpers.allowedTo = function(privilege, uid, cid, callback) {
}, },
function(next) { function(next) {
helpers.isMember(groups.isMember, 'cid:' + cid + ':privileges:groups:' + privilege, 'guests', function(err, isMember) { helpers.isMember(groups.isMember, 'cid:' + cid + ':privileges:groups:' + privilege, 'guests', function(err, isMember) {
next(err, privilege !== 'find' ? isMember : isMember !== false); next(err, privilege !== 'find' && privilege !== 'read' ? isMember === true : isMember !== false);
}); });
} }
], function(err, results) { ], function(err, results) {
callback(err, results[0] && results[1]); callback(err, results[0] && (results[1] || results[1] === null));
}); });
} }

@ -55,6 +55,16 @@ module.exports = function(privileges) {
}); });
}; };
privileges.topics.can = function(privilege, tid, uid, callback) {
topics.getTopicField(tid, 'cid', function(err, cid) {
if (err) {
return callback(err);
}
privileges.categories.can(privilege, cid, uid, callback);
});
};
privileges.topics.canRead = function(tid, uid, callback) { privileges.topics.canRead = function(tid, uid, callback) {
topics.getTopicField(tid, 'cid', function(err, cid) { topics.getTopicField(tid, 'cid', function(err, cid) {
if (err) { if (err) {

@ -49,10 +49,6 @@ var stopTracking = function(replyObj) {
}; };
SocketModules.composer.push = function(socket, pid, callback) { SocketModules.composer.push = function(socket, pid, callback) {
if(!socket.uid && parseInt(meta.config.allowGuestPosting, 10) !== 1) {
return callback(new Error('[[error:not-logged-in]]'));
}
posts.getPostFields(pid, ['content'], function(err, postData) { posts.getPostFields(pid, ['content'], function(err, postData) {
if(err || (!postData && !postData.content)) { if(err || (!postData && !postData.content)) {
return callback(err || new Error('[[error:invalid-pid]]')); return callback(err || new Error('[[error:invalid-pid]]'));

@ -19,11 +19,6 @@ var async = require('async'),
SocketPosts.reply = function(socket, data, callback) { SocketPosts.reply = function(socket, data, callback) {
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
return callback(new Error('[[error:not-logged-in]]'));
}
if(!data || !data.tid || !data.content) { if(!data || !data.tid || !data.content) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }

@ -21,10 +21,6 @@ SocketTopics.post = function(socket, data, callback) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
return callback(new Error('[[error:not-logged-in]]'));
}
topics.post({ topics.post({
uid: socket.uid, uid: socket.uid,
title: data.title, title: data.title,

@ -154,10 +154,6 @@ var bcrypt = require('bcryptjs'),
}; };
User.isReadyToPost = function(uid, callback) { User.isReadyToPost = function(uid, callback) {
if (meta.config.allowGuestPosting && parseInt(uid, 10) === 0) {
return callback();
}
async.parallel({ async.parallel({
banned: function(next) { banned: function(next) {
User.getUserField(uid, 'banned', next); User.getUserField(uid, 'banned', next);

Loading…
Cancel
Save