Fix cross-domain cookie issue

This commit is contained in:
calzoneman 2014-02-26 10:50:59 -06:00
parent ced68d9304
commit 93d5980f05
7 changed files with 31 additions and 7 deletions

View file

@ -106,6 +106,7 @@ function handleLoginPage(req, res) {
*/
function handleLogout(req, res) {
res.clearCookie("auth");
res.clearCookie("auth", { domain: Config.get("http.root-domain") });
// Try to find an appropriate redirect
var ref = req.header("referrer");
if (!ref) {

View file

@ -13,7 +13,9 @@ function merge(locals) {
var _locals = {
siteTitle: Config.get("html-template.title"),
siteDescription: Config.get("html-template.description"),
siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery"
siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery",
loginDomain: Config.get("https.enabled") ? Config.get("https.domain")+":"+Config.get("https.port")
: Config.get("http.domain")+":"+Config.get("http.port")
};
if (typeof locals !== "object") {
return _locals;

View file

@ -64,12 +64,13 @@ function logRequest(req, status) {
function cookieall(res, name, val, opts) {
res.cookie(name, val, opts);
opts.domain = Config.get("http.domain");
res.cookie(name, val, opts);
if (Config.get("https.enabled")) {
opts.domain = Config.get("https.domain");
res.cookie(name, val, opts);
opts.domain = Config.get("http.root-domain");
if (Config.get("http.domain").indexOf(opts.domain) === -1) {
opts.domain = Config.get("http.domain");
}
res.cookie(name, val, opts);
}
/**