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", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.17.2", "version": "3.17.3",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

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