diff --git a/channel.js b/channel.js index 95595a16..52b13904 100644 --- a/channel.js +++ b/channel.js @@ -139,18 +139,21 @@ Channel.prototype.saveRank = function(user) { console.log("MySQL Connection Failed"); return false; } - var query = 'UPDATE chan_{1}_ranks SET rank={2} WHERE name={3}' + var query = 'UPDATE chan_{1}_ranks SET rank="{2}" WHERE name="{3}"' .replace(/\{1\}/, this.name) .replace(/\{2\}/, user.rank) .replace(/\{3\}/, user.name); + console.log(query); var results = db.querySync(query); + console.log("saveRank update: " + results); // Gonna have to insert a new one, bugger - if(!results) { - var query = 'INSERT INTO chan_{1}_ranks SET VALUES({2}, {3})' + if(!results.fetchAllSync) { + var query = 'INSERT INTO chan_{1}_ranks (`name`, `rank`) VALUES ("{2}", "{3}")' .replace(/\{1\}/, this.name) .replace(/\{2\}/, user.name) .replace(/\{3\}/, user.rank); results = db.querySync(query); + console.log("saveRank insert: " + results); } db.closeSync(); return results; diff --git a/user.js b/user.js index 1bca89c1..8f179523 100644 --- a/user.js +++ b/user.js @@ -275,6 +275,7 @@ User.prototype.login = function(name, sha256) { else { var row; if((row = Auth.login(name, sha256))) { + this.loggedIn = true; this.socket.emit('login', { success: true });