From 33f775051dfcd4642cb08a2799b8410fd828d5aa Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 10 Aug 2016 22:20:53 -0700 Subject: [PATCH] Fixes for bot logins --- src/database/accounts.js | 4 ++-- src/user.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/database/accounts.js b/src/database/accounts.js index 5128e858..3c0e4846 100644 --- a/src/database/accounts.js +++ b/src/database/accounts.js @@ -134,7 +134,7 @@ module.exports = { callback(err, null); return; } - + if (accts.length >= Config.get("max-accounts-per-ip")) { delete registrationLock[lname]; callback("You have registered too many accounts from this "+ @@ -207,7 +207,7 @@ module.exports = { the hashes match. */ - db.query("SELECT name,password,global_rank FROM `users` WHERE name=?", + db.query("SELECT name,password,global_rank,time FROM `users` WHERE name=?", [name], function (err, rows) { if (err) { diff --git a/src/user.js b/src/user.js index f1ffb91f..e2bd66e8 100644 --- a/src/user.js +++ b/src/user.js @@ -288,6 +288,7 @@ User.prototype.login = function (name, pw) { } self.account.name = user.name; + self.registrationTime = new Date(user.time); self.setFlag(Flags.U_REGISTERED); self.refreshAccount(function (err, account) { if (err) { @@ -451,11 +452,11 @@ User.prototype.refreshAccount = function (cb) { User.prototype.getFirstSeenTime = function getFirstSeenTime() { if (this.registrationTime && this.socket.ipSessionFirstSeen) { - return Math.min(this.registrationTime.getTime(), this.socket.ipSessionFirstSeen); + return Math.min(this.registrationTime.getTime(), this.socket.ipSessionFirstSeen.getTime()); } else if (this.registrationTime) { return this.registrationTime.getTime(); } else if (this.socket.ipSessionFirstSeen) { - return this.socket.ipSessionFirstSeen; + return this.socket.ipSessionFirstSeen.getTime(); } else { Logger.errlog.log(`User "${this.getName()}" (IP: ${this.realip}) has neither ` + "an IP sesion first seen time nor a registered account.");