From d1bcf3ec141d72bc43fdd699a312814cca0e04ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 4 Jan 2019 11:53:07 +0100 Subject: [PATCH] Fixes banning users, Closes #454 --- server/handlers/chat.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/handlers/chat.js b/server/handlers/chat.js index c9cff7f5..5ca95b84 100644 --- a/server/handlers/chat.js +++ b/server/handlers/chat.js @@ -244,7 +244,7 @@ function checkIfChatEnabled(channel, socket, callback) { function checkIfUserIsBanned(channel, socket, guid, callback, callback_error) { var connection_id = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); - db.collection(channel + "_banned_chat").find({connection_id: connection_id}, function(err, docs) { + db.collection(channel + "_banned_chat").find({$or: [{connection_id: connection_id}, {connection_id: guid}]}, function(err, docs) { if(docs.length == 0) callback(); else { db.collection("user_names").findAndModify({query: {guid, guid}, update: {$addToSet:{channels: channel}}}, function(e, d){ @@ -339,7 +339,8 @@ function namechange(data, guid, socket, tried, callback) { var old_name = names[0].name; db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function() {}); } - var updateElement = {$set: {name: name, icon: icon}}; + var connection_id = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]); + var updateElement = {$set: {name: name, icon: icon, connection_id: connection_id}}; if(data.hasOwnProperty("channel") && data.channel != "") { updateElement["$addToSet"] = {channels: data.channel}; }