mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 01:56:12 +01:00
fix: restrict getUsersInRoom to members
This commit is contained in:
@@ -113,11 +113,14 @@ SocketModules.chats.getUsersInRoom = async function (socket, data) {
|
||||
if (!data || !data.roomId) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
const [userData, isOwner] = await Promise.all([
|
||||
Messaging.getUsersInRoom(data.roomId, 0, -1),
|
||||
const [isUserInRoom, isOwner, userData] = await Promise.all([
|
||||
Messaging.isUserInRoom(socket.uid, data.roomId),
|
||||
Messaging.isRoomOwner(socket.uid, data.roomId),
|
||||
Messaging.getUsersInRoom(data.roomId, 0, -1),
|
||||
]);
|
||||
|
||||
if (!isUserInRoom) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
userData.forEach((user) => {
|
||||
user.canKick = (parseInt(user.uid, 10) !== parseInt(socket.uid, 10)) && isOwner;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user