From 47c71b5a372bd210200557ab1eeaea3afdac7ec2 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 28 Oct 2015 15:10:27 -0400 Subject: [PATCH] closes https://github.com/NodeBB/nodebb-theme-persona/issues/181 --- src/privileges/categories.js | 3 +++ src/socket.io/posts/tools.js | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 31d1deeeb3..d51edbb9a8 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -191,6 +191,9 @@ module.exports = function(privileges) { }; privileges.categories.isAdminOrMod = function(cid, uid, callback) { + if (!parseInt(uid, 10)) { + return callback(null, false); + } helpers.some([ function (next) { user.isModerator(uid, cid, next); diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js index fc4491ea44..d05c2b74be 100644 --- a/src/socket.io/posts/tools.js +++ b/src/socket.io/posts/tools.js @@ -13,9 +13,6 @@ var favourites = require('../../favourites'); module.exports = function(SocketPosts) { SocketPosts.loadPostTools = function(socket, data, callback) { - if (!socket.uid) { - return; - } if (!data) { return callback(new Error('[[error:invalid-data]]')) } @@ -37,7 +34,7 @@ module.exports = function(SocketPosts) { results.posts.tools = []; // TODO: add filter for this results.posts.deleted = parseInt(results.posts.deleted, 10) === 1; results.posts.favourited = results.favourited[0]; - results.posts.selfPost = socket.uid === parseInt(results.posts.uid, 10); + results.posts.selfPost = socket.uid && socket.uid === parseInt(results.posts.uid, 10); results.posts.display_moderator_tools = results.isAdminOrMod || results.posts.selfPost; results.posts.display_move_tools = results.isAdminOrMod; callback(null, results);