mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
anons cant edit after posting #365
This commit is contained in:
@@ -344,8 +344,8 @@ var socket,
|
|||||||
|
|
||||||
app.createNewPosts = function (data) {
|
app.createNewPosts = function (data) {
|
||||||
if (data.posts[0].uid !== app.uid) {
|
if (data.posts[0].uid !== app.uid) {
|
||||||
data.posts[0].display_moderator_tools = 'none';
|
data.posts[0].display_moderator_tools = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
||||||
translator.translate(html, function(translatedHTML) {
|
translator.translate(html, function(translatedHTML) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ define(function() {
|
|||||||
window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no');
|
window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.facebook-share').on('click', function () {
|
$('.facebook-share').on('click', function () {
|
||||||
window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no');
|
window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no');
|
||||||
return false;
|
return false;
|
||||||
@@ -548,7 +548,7 @@ define(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:post.privileges', function(privileges) {
|
socket.on('api:post.privileges', function(privileges) {
|
||||||
if (privileges.editable) toggle_mod_tools(privileges.pid, true);
|
toggle_mod_tools(privileges.pid, privileges.editable);
|
||||||
});
|
});
|
||||||
|
|
||||||
function adjust_rep(value, pid, uid) {
|
function adjust_rep(value, pid, uid) {
|
||||||
|
|||||||
@@ -25,7 +25,13 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
PostTools.privileges = function(pid, uid, callback) {
|
PostTools.privileges = function(pid, uid, callback) {
|
||||||
//todo: break early if one condition is true
|
if(uid == 0) {
|
||||||
|
callback({
|
||||||
|
editable: false,
|
||||||
|
view_deleted: false
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function getThreadPrivileges(next) {
|
function getThreadPrivileges(next) {
|
||||||
posts.getPostField(pid, 'tid', function(tid) {
|
posts.getPostField(pid, 'tid', function(tid) {
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ var RDB = require('./redis.js'),
|
|||||||
var socketData = {
|
var socketData = {
|
||||||
posts: [postData]
|
posts: [postData]
|
||||||
};
|
};
|
||||||
|
|
||||||
io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
|
io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
|
||||||
io.sockets.in('recent_posts').emit('event:new_post', socketData);
|
io.sockets.in('recent_posts').emit('event:new_post', socketData);
|
||||||
io.sockets.in('user/' + uid).emit('event:new_post', socketData);
|
io.sockets.in('user/' + uid).emit('event:new_post', socketData);
|
||||||
|
|||||||
@@ -541,8 +541,15 @@ module.exports.init = function(io) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:posts.edit', function(data) {
|
socket.on('api:posts.edit', function(data) {
|
||||||
|
if(!uid) {
|
||||||
if (!data.title || data.title.length < topics.minimumTitleLength) {
|
socket.emit('event:alert', {
|
||||||
|
title: 'Can't edit',
|
||||||
|
message: 'Guests can't edit posts!',
|
||||||
|
type: 'warning',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else if (!data.title || data.title.length < topics.minimumTitleLength) {
|
||||||
topics.emitTitleTooShortAlert(socket);
|
topics.emitTitleTooShortAlert(socket);
|
||||||
return;
|
return;
|
||||||
} else if (!data.content || data.content.length < require('../public/config.json').minimumPostLength) {
|
} else if (!data.content || data.content.length < require('../public/config.json').minimumPostLength) {
|
||||||
|
|||||||
Reference in New Issue
Block a user