From 799276a90a9261ebf64fdf213dff3e6c60e4165d Mon Sep 17 00:00:00 2001 From: Bill Hunt Date: Thu, 3 Sep 2015 11:56:10 -0400 Subject: [PATCH] Fix up session saving. Resolves #11 --- lib/connect-mysql-session.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/connect-mysql-session.js b/lib/connect-mysql-session.js index a06f756..3f8b2c0 100644 --- a/lib/connect-mysql-session.js +++ b/lib/connect-mysql-session.js @@ -84,24 +84,25 @@ module.exports = function (connect) { session.passport.user = session.user; } - - that.set(sid, session); } + } - if(!session.cookie) - { - session.cookie = {}; - } - if (!(session.cookie && session.cookie.expires) && session.last_activity) - { - session.cookie.expires = session.last_activity + parseInt(sails.config.session.cookie.maxAge); - } - if(!(session.cookie && session.cookie.originalMaxAge)) - { - session.cookie.originalMaxAge = sails.config.session.cookie.maxAge; - } - session.cookie.domain = sails.config.session.cookie.domain; + if(!session.cookie) + { + session.cookie = {}; + } + if (!(session.cookie && session.cookie.expires) && session.last_activity) + { + session.cookie.expires = session.last_activity + parseInt(sails.config.session.cookie.maxAge); } + if(!(session.cookie && session.cookie.originalMaxAge)) + { + session.cookie.originalMaxAge = sails.config.session.cookie.maxAge; + } + session.cookie.domain = sails.config.session.cookie.domain; + + that.set(sid, session); + fn(null, session); })