mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: allow guests to load topic tools if they have privilege to view them
display errors from topics.loadTopicTools
This commit is contained in:
@@ -225,7 +225,7 @@ define('forum/topic/threadTools', [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dropdownMenu.html(helpers.generatePlaceholderWave([8, 8, 8]));
|
dropdownMenu.html(helpers.generatePlaceholderWave([8, 8, 8]));
|
||||||
const data = await socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid });
|
const data = await socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }).catch(alerts.error);
|
||||||
const html = await app.parseAndTranslate('partials/topic/topic-menu-list', data);
|
const html = await app.parseAndTranslate('partials/topic/topic-menu-list', data);
|
||||||
$(dropdownMenu).attr('data-loaded', 'true').html(html);
|
$(dropdownMenu).attr('data-loaded', 'true').html(html);
|
||||||
hooks.fire('action:topic.tools.load', {
|
hooks.fire('action:topic.tools.load', {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ const plugins = require('../../plugins');
|
|||||||
|
|
||||||
module.exports = function (SocketTopics) {
|
module.exports = function (SocketTopics) {
|
||||||
SocketTopics.loadTopicTools = async function (socket, data) {
|
SocketTopics.loadTopicTools = async function (socket, data) {
|
||||||
if (!socket.uid) {
|
|
||||||
throw new Error('[[error:no-privileges]]');
|
|
||||||
}
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw new Error('[[error:invalid-data]]');
|
throw new Error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
@@ -21,7 +18,7 @@ module.exports = function (SocketTopics) {
|
|||||||
if (!topicData) {
|
if (!topicData) {
|
||||||
throw new Error('[[error:no-topic]]');
|
throw new Error('[[error:no-topic]]');
|
||||||
}
|
}
|
||||||
if (!userPrivileges['topics:read']) {
|
if (!userPrivileges['topics:read'] || !userPrivileges.view_thread_tools) {
|
||||||
throw new Error('[[error:no-privileges]]');
|
throw new Error('[[error:no-privileges]]');
|
||||||
}
|
}
|
||||||
topicData.privileges = userPrivileges;
|
topicData.privileges = userPrivileges;
|
||||||
|
|||||||
Reference in New Issue
Block a user