Fix login race condition (#583)

This commit is contained in:
calzoneman 2016-06-26 16:21:15 -07:00
parent 8ede986d22
commit e9fdb1a7e5
2 changed files with 14 additions and 9 deletions

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.17.2",
"version": "3.17.3",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View file

@ -323,15 +323,20 @@ Channel.prototype.joinUser = function (user, data) {
}
if (self.is(Flags.C_REGISTERED)) {
user.refreshAccount({ channel: self.name }, function (err, account) {
if (err) {
Logger.errlog.log("user.refreshAccount failed at Channel.joinUser");
Logger.errlog.log(err.stack);
self.refCounter.unref("Channel::user");
return;
}
user.waitFlag(Flags.U_LOGGED_IN, () => {
user.refreshAccount({
channel: self.name,
name: user.getName()
}, function (err, account) {
if (err) {
Logger.errlog.log("user.refreshAccount failed at Channel.joinUser");
Logger.errlog.log(err.stack);
self.refCounter.unref("Channel::user");
return;
}
afterAccount();
afterAccount();
});
});
} else {
afterAccount();