mirror of https://github.com/calzoneman/sync.git
Fix potential race condition
This commit is contained in:
parent
03ba657783
commit
256a951531
|
@ -252,7 +252,6 @@ User.prototype.login = function (name, pw) {
|
|||
self.setFlag(Flags.U_LOGGING_IN);
|
||||
|
||||
db.users.verifyLogin(name, pw, function (err, user) {
|
||||
self.clearFlag(Flags.U_LOGGING_IN);
|
||||
if (err) {
|
||||
if (err === "Invalid username/password combination") {
|
||||
Logger.eventlog.log("[loginfail] Login failed (bad password): " + name
|
||||
|
@ -263,6 +262,7 @@ User.prototype.login = function (name, pw) {
|
|||
success: false,
|
||||
error: err
|
||||
});
|
||||
self.clearFlag(Flags.U_LOGGING_IN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,8 @@ User.prototype.login = function (name, pw) {
|
|||
if (err) {
|
||||
Logger.errlog.log("[SEVERE] getAccount failed for user " + user.name);
|
||||
Logger.errlog.log(err);
|
||||
user.clearFlag(Flags.U_REGISTERED);
|
||||
self.clearFlag(Flags.U_REGISTERED);
|
||||
self.clearFlag(Flags.U_LOGGING_IN);
|
||||
return;
|
||||
}
|
||||
self.socket.emit("login", {
|
||||
|
@ -289,6 +290,7 @@ User.prototype.login = function (name, pw) {
|
|||
self.channel.logger.log(self.longip + " logged in as " + user.name);
|
||||
}
|
||||
self.setFlag(Flags.U_LOGGED_IN);
|
||||
self.clearFlag(Flags.U_LOGGING_IN);
|
||||
self.emit("login", self.account);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue