From 135545554897c04e030014e5ef8c9bf2f2e9a111 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 25 Jan 2014 17:47:38 -0600 Subject: [PATCH] Address race condition --- lib/channel-new.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/channel-new.js b/lib/channel-new.js index 87d5082a..6e761a10 100644 --- a/lib/channel-new.js +++ b/lib/channel-new.js @@ -455,6 +455,7 @@ Channel.prototype.join = function (user, password) { } user.socket.emit("rank", user.rank); + user.emit("channelRank", user.rank); }); }); @@ -517,8 +518,8 @@ Channel.prototype.join = function (user, password) { if (self.opts.password !== false && user.rank < 2) { if (password !== self.opts.password) { user.socket.emit("needPassword", typeof password !== "undefined"); - user.whenLoggedIn(function () { - if (user.rank >= 2) { + user.once("channelRank", function (r) { + if (r >= 2) { self.join(user); } });