From 341d17c7b93b69d59e7beff89cdd48b206bc5795 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 1 Mar 2014 17:37:59 -0600 Subject: [PATCH] Fixes --- lib/channel.js | 11 +++++++---- lib/config.js | 4 ++++ lib/web/account.js | 4 ++-- lib/web/auth.js | 13 +++++++------ www/css/cytube.css | 2 +- www/js/util.js | 2 +- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/channel.js b/lib/channel.js index 95e7fea8..02bd175d 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -909,7 +909,8 @@ Channel.prototype.banIP = function (actor, ip, name, reason, range) { } self.logger.log("[mod] " + actor.name + " banned " + ip + " (" + name + ")"); - self.sendModMessage(actor.name + " banned " + ip + " (" + name + ")", self.permissions.ban); + self.sendModMessage(actor.name + " banned " + util.maskIP(ip) + + " (" + name + ")", self.permissions.ban); // If in the channel already, kick the banned user for (var i = 0; i < self.users.length; i++) { if (self.users[i].ip === ip) { @@ -3034,7 +3035,8 @@ Channel.prototype.handleSetRank = function (user, data) { var name = data.user.substring(0, 20); var rank = data.rank; - if (isNaN(rank) || rank < 1 || rank >= user.rank) { + if (isNaN(rank) || rank < 1 || (rank >= user.rank && !(user.rank === 4 && + rank === 4))) { user.socket.emit("channelRankFail", { msg: "Updating user rank failed: You can't promote someone to equal or " + "higher rank than yourself, or demote them below rank 1." @@ -3064,7 +3066,7 @@ Channel.prototype.handleSetRank = function (user, data) { return; } - if (oldrank >= user.rank) { + if (oldrank >= user.rank && !(oldrank === 4 && user.rank === 4)) { user.socket.emit("channelRankFail", { msg: "Updating user rank failed: " + name + " has equal or higher " + "rank than you" @@ -3100,7 +3102,8 @@ Channel.prototype.handleSetRank = function (user, data) { }; if (receiver) { - if (Math.max(receiver.rank, receiver.global_rank) > user.rank) { + var receiverrank = Math.max(receiver.rank, receiver.global_rank); + if (receiverrank > user.rank && !(receiverrank === 4 && user.rank === 4)) { user.socket.emit("channelRankFail", { msg: "Updating user rank failed: " + receiver.name + " has higher rank "+ "than you." diff --git a/lib/config.js b/lib/config.js index b4207eed..eb740525 100644 --- a/lib/config.js +++ b/lib/config.js @@ -146,6 +146,10 @@ function preprocessConfig(cfg) { var root = cfg.http["root-domain"]; root = root.replace(/^\.*/, ""); cfg.http["root-domain"] = root; + if (root.indexOf(".") !== -1) { + root = "." + root; + } + cfg.http["root-domain-dotted"] = root; // Setup nodemailer cfg.mail.nodemailer = nodemailer.createTransport( diff --git a/lib/web/account.js b/lib/web/account.js index 5692a7f8..5b9df74a 100644 --- a/lib/web/account.js +++ b/lib/web/account.js @@ -611,14 +611,14 @@ function handlePasswordReset(req, res) { Logger.errlog.log("mail fail: " + err); sendJade(res, "account-passwordreset", { reset: false, - resetEmail: user.email, + resetEmail: email, resetErr: "Sending reset email failed. Please contact an " + "administrator for assistance." }); } else { sendJade(res, "account-passwordreset", { reset: true, - resetEmail: user.email, + resetEmail: email, resetErr: false }); } diff --git a/lib/web/auth.js b/lib/web/auth.js index 3d5ed208..d06d41e3 100644 --- a/lib/web/auth.js +++ b/lib/web/auth.js @@ -42,14 +42,15 @@ function handleLogin(req, res) { }); } else { var auth = user.name + ":" + user.hash; + console.log(Config.get("http.root-domain-dotted")); res.cookie("auth", auth, { - domain: "." + Config.get("http.root-domain"), + domain: Config.get("http.root-domain-dotted"), expires: new Date(Date.now() + 7*24*60*60*1000), httpOnly: true }); res.cookie("rank", user.global_rank, { - domain: "." + Config.get("http.root-domain"), + domain: Config.get("http.root-domain-dotted"), expires: new Date(Date.now() + 7*24*60*60*1000), }); @@ -140,8 +141,8 @@ function handleShimLogout(req, res) { res.clearCookie("auth"); res.clearCookie("rank"); - res.clearCookie("auth", { domain: "." + Config.get("http.root-domain") }); - res.clearCookie("rank", { domain: "." + Config.get("http.root-domain") }); + res.clearCookie("auth", { domain: Config.get("http.root-domain-dotted") }); + res.clearCookie("rank", { domain: Config.get("http.root-domain-dotted") }); if (redirect.match(/login|logout/)) { @@ -198,8 +199,8 @@ function handleLogout(req, res) { var host = req.host; if (host.indexOf(Config.get("http.root-domain")) !== -1) { - res.clearCookie("auth", { domain: Config.get("http.root-domain") }); - res.clearCookie("rank", { domain: Config.get("http.root-domain") }); + res.clearCookie("auth", { domain: Config.get("http.root-domain-dotted") }); + res.clearCookie("rank", { domain: Config.get("http.root-domain-dotted") }); } else { var dest = Config.get("http.full-address") + "/shimlogout?redirect=" + encodeURIComponent(ref); diff --git a/www/css/cytube.css b/www/css/cytube.css index 2d7585cf..312cc274 100644 --- a/www/css/cytube.css +++ b/www/css/cytube.css @@ -58,7 +58,7 @@ border-top-right-radius: 0; } -.linewrap { +.linewrap, .linewrap code { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ diff --git a/www/js/util.js b/www/js/util.js index 5f94e6d1..4de20da7 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -1939,7 +1939,7 @@ function formatCSModList() { .attr("data-toggle", "dropdown") .html("Edit ") .appendTo(dd); - if (CLIENT.rank <= entry.rank) { + if (CLIENT.rank <= entry.rank && !(CLIENT.rank === 4 && entry.rank === 4)) { toggle.addClass("disabled"); }