From 171d8b6635d9ba27b0aab64355805bdf41344a45 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Fri, 29 Jan 2016 13:26:00 -0500 Subject: [PATCH 1/7] 1.13.1 --- HISTORY.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 727834eb..ffb63d71 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,5 @@ -unreleased -========== +1.13.1 / 2016-01-29 +=================== * deps: parseurl@~1.3.1 - perf: enable strict mode diff --git a/package.json b/package.json index 8b945f2e..b9e15281 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-session", - "version": "1.13.0", + "version": "1.13.1", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)", "contributors": [ From 2cbc45cd4c89f94fa750d155a466ea1d7fa99dbc Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 15:28:45 +0530 Subject: [PATCH 2/7] Update index.js --- index.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 0de7c62f..f5aa4f90 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,6 @@ * MIT Licensed */ -'use strict'; - /** * Module dependencies. * @private @@ -138,11 +136,10 @@ function session(options){ } // generates the new session - store.generate = function(req){ - req.sessionID = generateId(req); + store.generate = function(req, customId, fn){ + req.sessionID = customId || generateId(req); req.session = new Session(req); req.session.cookie = new Cookie(cookieOptions); - if (cookieOptions.secure === 'auto') { req.session.cookie.secure = issecure(req, trustProxy); } @@ -262,7 +259,6 @@ function session(options){ return ret; } - if (shouldDestroy(req)) { // destroy session debug('destroying'); @@ -288,11 +284,11 @@ function session(options){ req.session.touch(); if (shouldSave(req)) { + req.session.save(function onsave(err) { if (err) { defer(next, err); } - writeend(); }); @@ -312,13 +308,14 @@ function session(options){ return writetop(); } + return _end.call(res, chunk, encoding); }; // generate the session - function generate() { + function generate(customId) { store.generate(req); - originalId = req.sessionID; + originalId = customId || req.sessionID; originalHash = hash(req.session); wrapmethods(req.session); } @@ -377,6 +374,7 @@ function session(options){ return false; } + return cookieId === req.sessionID && !shouldSave(req); } @@ -387,9 +385,14 @@ function session(options){ return false; } + // in case of rolling session, always reset the cookie + if (rollingSessions) { + return true; + } + return cookieId != req.sessionID ? saveUninitializedSession || isModified(req.session) - : rollingSessions || req.session.cookie.expires != null && isModified(req.session); + : req.session.cookie.expires != null && isModified(req.session); } // generate a session if the browser doesn't send a sessionID From 13cd69cb3be8623bd17b5e0e59ae083ad503788c Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 15:32:34 +0530 Subject: [PATCH 3/7] added customid support in regenerate method --- session/store.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/session/store.js b/session/store.js index ca3d4a9d..6102dde1 100644 --- a/session/store.js +++ b/session/store.js @@ -1,3 +1,4 @@ + /*! * Connect - session - Store * Copyright(c) 2010 Sencha Inc. @@ -5,8 +6,6 @@ * MIT Licensed */ -'use strict'; - /** * Module dependencies. */ @@ -37,10 +36,10 @@ Store.prototype.__proto__ = EventEmitter.prototype; * @api public */ -Store.prototype.regenerate = function(req, fn){ +Store.prototype.regenerate = function(req,customId, fn){ var self = this; this.destroy(req.sessionID, function(err){ - self.generate(req); + self.generate(req, customId, fn); fn(err); }); }; From 839cdca3595deaad28529d8e28d7603aa3c1688b Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 15:33:26 +0530 Subject: [PATCH 4/7] added customid support in regenerate method --- session/session.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/session/session.js b/session/session.js index c3c0f15a..8000e6eb 100644 --- a/session/session.js +++ b/session/session.js @@ -1,3 +1,4 @@ + /*! * Connect - session - Session * Copyright(c) 2010 Sencha Inc. @@ -5,8 +6,6 @@ * MIT Licensed */ -'use strict'; - /** * Expose Session. */ @@ -22,6 +21,7 @@ module.exports = Session; */ function Session(req, data) { + Object.defineProperty(this, 'req', { value: req }); Object.defineProperty(this, 'id', { value: req.sessionID }); @@ -119,7 +119,7 @@ Session.prototype.destroy = function(fn){ * @api public */ -Session.prototype.regenerate = function(fn){ - this.req.sessionStore.regenerate(this.req, fn); +Session.prototype.regenerate = function(customId, fn){ + this.req.sessionStore.regenerate(this.req, customId, fn); return this; }; From 0dde3e75ee4aba27f4fa0846da43782943098a3d Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 15:35:52 +0530 Subject: [PATCH 5/7] added use strict accidentally removed --- session/session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session/session.js b/session/session.js index 8000e6eb..b2d46c38 100644 --- a/session/session.js +++ b/session/session.js @@ -1,10 +1,10 @@ - /*! * Connect - session - Session * Copyright(c) 2010 Sencha Inc. * Copyright(c) 2011 TJ Holowaychuk * MIT Licensed */ +'use strict'; /** * Expose Session. From 2f24af3ed488fb2cd801c2fb61f83fb9c8836930 Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 15:37:40 +0530 Subject: [PATCH 6/7] changes comment section for regenerate method --- session/session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session/session.js b/session/session.js index b2d46c38..9b2c7d3c 100644 --- a/session/session.js +++ b/session/session.js @@ -114,11 +114,11 @@ Session.prototype.destroy = function(fn){ /** * Regenerate this request's session. * + * @param {string} customId * @param {Function} fn * @return {Session} for chaining * @api public */ - Session.prototype.regenerate = function(customId, fn){ this.req.sessionStore.regenerate(this.req, customId, fn); return this; From 1d22749aa46280a24a4ee3a993ba0772e6e1e2df Mon Sep 17 00:00:00 2001 From: Rohit Choudhary Date: Fri, 5 Feb 2016 17:21:35 +0530 Subject: [PATCH 7/7] removed accidental removal --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f5aa4f90..54d8f0c0 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ - +'use strict'; /** * Module dependencies. * @private @@ -392,7 +392,7 @@ function session(options){ return cookieId != req.sessionID ? saveUninitializedSession || isModified(req.session) - : req.session.cookie.expires != null && isModified(req.session); + :rollingSessions || req.session.cookie.expires != null && isModified(req.session); } // generate a session if the browser doesn't send a sessionID