removing allowGuestPosting logic in NodeBB

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

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

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

@ -24,8 +24,7 @@ apiController.getConfig = function(req, res, next) {
config.minimumPasswordLength = meta.config.minimumPasswordLength;
config.maximumSignatureLength = meta.config.maximumSignatureLength;
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
config.allowGuestPosting = parseInt(meta.config.allowGuestPosting, 10) === 1;
config.allowGuestSearching = parseInt(meta.config.allowGuestPosting, 10) === 1;
config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1;
config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1;
config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 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) {
db.getSetMembers('group:' + groupListKey + ':members', function(err, gids) {
async.some(gids, function(gid, next) {
Groups.isMember(uid, gid, function(err, isMember) {
db.getSetMembers('group:' + groupListKey + ':members', function(err, groupNames) {
groupNames = internals.removeEphemeralGroups(groupNames);
if (groupNames.length === 0) {
return callback(null, null);
}
async.some(groupNames, function(groupName, next) {
Groups.isMember(uid, groupName, function(err, isMember) {
if (!err && isMember) {
next(true);
} else {

@ -40,11 +40,11 @@ helpers.allowedTo = function(privilege, uid, cid, callback) {
},
function(next) {
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) {
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) {
topics.getTopicField(tid, 'cid', function(err, cid) {
if (err) {

@ -49,10 +49,6 @@ var stopTracking = function(replyObj) {
};
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) {
if(err || (!postData && !postData.content)) {
return callback(err || new Error('[[error:invalid-pid]]'));

@ -19,11 +19,6 @@ var async = require('async'),
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) {
return callback(new Error('[[error:invalid-data]]'));
}

@ -21,10 +21,6 @@ SocketTopics.post = function(socket, data, callback) {
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({
uid: socket.uid,
title: data.title,

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

Loading…
Cancel
Save