diff --git a/lib/io/ioserver.js b/lib/io/ioserver.js index 06660781..11c1dfe1 100644 --- a/lib/io/ioserver.js +++ b/lib/io/ioserver.js @@ -108,6 +108,7 @@ function handleConnection(sock) { guest: false }); user.socket.emit("rank", user.global_rank); + Logger.syslog.log(ip + " logged in as " + user.name); } else { user.socket.emit("rank", -1); } diff --git a/lib/server.js b/lib/server.js index 9ad72f77..14a4dfd2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -167,6 +167,7 @@ Server.prototype.unloadChannel = function (chan) { } } + Logger.syslog.log("Unloaded channel " + chan.name); // Empty all outward references from the channel var keys = Object.keys(chan); for (var i in keys) { diff --git a/lib/user.js b/lib/user.js index 8f7ffc8a..1d5d5fe0 100644 --- a/lib/user.js +++ b/lib/user.js @@ -67,8 +67,10 @@ function User(socket) { pw = ""; } - if (!pw) { + if (!pw && !self.loggingIn && !self.loggedIn) { self.guestLogin(name); + } else if (pw && !self.loggingIn && !self.loggedIn) { + self.login(name, pw); } }); @@ -472,6 +474,41 @@ User.prototype.whenLoggedIn = function (fn) { } }; +User.prototype.login = function (name, pw) { + var self = this; + self.loggingIn = true; + + db.users.verifyLogin(name, pw, function (err, user) { + self.loggingIn = false; + if (err) { + if (err === "Invalid username/password combination") { + Logger.eventlog.log("[loginfail] Login failed (bad password): " + name + + "@" + webserver.ipForRequest(req)); + } + + self.socket.emit("login", { + success: false, + error: err + }); + return; + } + + self.rank = self.global_rank = user.global_rank; + self.name = user.name; + self.loggedIn = true; + self.socket.emit("login", { + success: true, + name: user.name + }); + self.socket.emit("rank", self.rank); + Logger.syslog.log(self.ip + " logged in as " + name); + if (self.inChannel()) { + self.channel.logger.log(self.ip + " logged in as " + name); + } + self.emit("login"); + }); +}; + var lastguestlogin = {}; User.prototype.guestLogin = function (name) { var self = this; @@ -545,6 +582,7 @@ User.prototype.guestLogin = function (name) { }); // TODO you shouldn't be able to guest login without being in a channel + Logger.syslog.log(self.ip + " signed in as " + name); if (self.inChannel()) { self.channel.logger.log(self.ip + " signed in as " + name); } diff --git a/www/assets/js/util.js b/www/assets/js/util.js index d2854510..94d1ac68 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -1395,7 +1395,7 @@ function addChatMessage(data) { function fluidLayout() { $(".container").removeClass("container").addClass("container-fluid"); - $("footer .container").removeClass("container-fluid").addClass("container"); + $("footer .container-fluid").removeClass("container-fluid").addClass("container"); $("body").addClass("fluid"); resizeStuff(); }