Fix corner case causing TypeError in userJoin
I believe this issue was caused by a single user in the channel being kicked for a duplicate login, thereby unloading the channel while the for loop was iterating, so this.users became undefined before the loop exited and thus there was a TypeError for reading this.users.length
This commit is contained in:
parent
df16458f98
commit
3460b0544c
|
@ -881,16 +881,16 @@ Channel.prototype.userJoin = function(user, password) {
|
||||||
Logger.errlog.log("keys: " + Object.keys(this).join(","));
|
Logger.errlog.log("keys: " + Object.keys(this).join(","));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(var i = 0; i < this.users.length; i++) {
|
this.users.forEach(function (u) {
|
||||||
if(this.users[i].name.toLowerCase() == user.name.toLowerCase()) {
|
if(u.name.toLowerCase() == user.name.toLowerCase()) {
|
||||||
if (this.users[i] == user) {
|
if (u == user) {
|
||||||
Logger.errlog.log("Wat: userJoin() called on user "+
|
Logger.errlog.log("Wat: userJoin() called on user "+
|
||||||
"already in the channel");
|
"already in the channel");
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
this.kick(this.users[i], "Duplicate login");
|
this.kick(u, "Duplicate login");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.users.push(user);
|
this.users.push(user);
|
||||||
|
|
Loading…
Reference in a new issue