diff --git a/lib/channel.js b/lib/channel.js index 50a8edc4..c980ab12 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -430,12 +430,12 @@ Channel.prototype.getIPRank = function (ip, callback) { return; } - var rank = res.reduce(function (a, b) { + var globalRank = res.reduce(function (a, b) { return Math.max(a, b); }, 0); if (!self.registered) { - callback(null, rank); + callback(null, globalRank); return; } @@ -452,7 +452,7 @@ Channel.prototype.getIPRank = function (ip, callback) { var rank = res.reduce(function (a, b) { return Math.max(a, b); - }, rank); + }, globalRank); callback(null, rank); }); diff --git a/lib/database/channels.js b/lib/database/channels.js index 282c8953..17369188 100644 --- a/lib/database/channels.js +++ b/lib/database/channels.js @@ -350,7 +350,7 @@ module.exports = { return; } - callback(null, rows); + callback(null, rows.map(function (r) { return r.rank; })); }); }, diff --git a/lib/web/auth.js b/lib/web/auth.js index d06d41e3..210efde2 100644 --- a/lib/web/auth.js +++ b/lib/web/auth.js @@ -42,7 +42,11 @@ function handleLogin(req, res) { }); } else { var auth = user.name + ":" + user.hash; - console.log(Config.get("http.root-domain-dotted")); + res.cookie("auth", auth, { + expires: new Date(Date.now() + 7*24*60*60*1000), + httpOnly: true + }); + res.cookie("auth", auth, { domain: Config.get("http.root-domain-dotted"), expires: new Date(Date.now() + 7*24*60*60*1000),