diff --git a/package.json b/package.json index 01a41d6d..57d0fd15 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.23.0", + "version": "3.23.1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/src/channel/channel.js b/src/channel/channel.js index c255f842..e293624f 100644 --- a/src/channel/channel.js +++ b/src/channel/channel.js @@ -334,6 +334,12 @@ Channel.prototype.joinUser = function (user, data) { if (!error) { user.setChannelRank(rank); user.setFlag(Flags.U_HAS_CHANNEL_RANK); + if (user.inChannel()) { + self.broadcastAll("setUserRank", { + name: user.getName(), + rank: rank + }); + } } }); }); diff --git a/src/database/accounts.js b/src/database/accounts.js index ce9a44a4..ce7f015f 100644 --- a/src/database/accounts.js +++ b/src/database/accounts.js @@ -16,6 +16,17 @@ function wildcardSimilarChars(name) { return name.replace(/_/g, "\\_").replace(/[Il1oO0]/g, "_"); } +function parseProfile(data) { + try { + var profile = JSON.parse(data.profile); + profile.image = profile.image || ""; + profile.text = profile.text || ""; + data.profile = profile; + } catch (error) { + data.profile = { image: "", text: "" }; + } +} + module.exports = { init: function () { }, @@ -83,15 +94,7 @@ module.exports = { return callback("User does not exist"); } - try { - var profile = JSON.parse(rows[0].profile); - profile.image = profile.image || ""; - profile.text = profile.text || ""; - rows[0].profile = profile; - } catch (error) { - rows[0].profile = { image: "", text: "" }; - } - + parseProfile(rows[0]); callback(null, rows[0]); }); }, @@ -216,7 +219,7 @@ module.exports = { the hashes match. */ - db.query("SELECT name,password,global_rank,time FROM `users` WHERE name=?", + db.query("SELECT * FROM `users` WHERE name=?", [name], function (err, rows) { if (err) { @@ -235,6 +238,7 @@ module.exports = { } else if (!match) { callback("Invalid username/password combination", null); } else { + parseProfile(rows[0]); callback(null, rows[0]); } });