mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 05:40:43 +01:00
fix: don't allow joining topic_<tid> & category_<cid>
socket.io rooms if you don't have relevant privileges
This commit is contained in:
@@ -5,6 +5,7 @@ const os = require('os');
|
||||
const user = require('../user');
|
||||
const meta = require('../meta');
|
||||
const topics = require('../topics');
|
||||
const privileges = require('../privileges');
|
||||
|
||||
const SocketMeta = module.exports;
|
||||
SocketMeta.rooms = {};
|
||||
@@ -44,6 +45,20 @@ SocketMeta.rooms.enter = async function (socket, data) {
|
||||
throw new Error('[[error:not-allowed]]');
|
||||
}
|
||||
|
||||
if (data.enter && data.enter.startsWith('topic_')) {
|
||||
const tid = data.enter.split('_').pop();
|
||||
if (!await privileges.topics.can('topics:read', tid, socket.uid)) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
}
|
||||
|
||||
if (data.enter && data.enter.startsWith('category_')) {
|
||||
const cid = data.enter.split('_').pop();
|
||||
if (!await privileges.categories.can('read', cid, socket.uid)) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
}
|
||||
|
||||
leaveCurrentRoom(socket);
|
||||
|
||||
if (data.enter) {
|
||||
|
||||
Reference in New Issue
Block a user