diff --git a/lib/channel.js b/lib/channel.js index be089cf4..b00bdd7b 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -881,16 +881,16 @@ Channel.prototype.userJoin = function(user, password) { Logger.errlog.log("keys: " + Object.keys(this).join(",")); return; } - for(var i = 0; i < this.users.length; i++) { - if(this.users[i].name.toLowerCase() == user.name.toLowerCase()) { - if (this.users[i] == user) { + this.users.forEach(function (u) { + if(u.name.toLowerCase() == user.name.toLowerCase()) { + if (u == user) { Logger.errlog.log("Wat: userJoin() called on user "+ "already in the channel"); - break; + return; } - this.kick(this.users[i], "Duplicate login"); + this.kick(u, "Duplicate login"); } - } + }); } this.users.push(user);