diff --git a/lib/sessionmanager.js b/lib/sessionmanager.js index edd2535f..c39bc6e5 100644 --- a/lib/sessionmanager.js +++ b/lib/sessionmanager.js @@ -12,6 +12,8 @@ function SessionManager(options, serializeUser) { SessionManager.prototype.logIn = function(req, user, cb) { console.log('SM: logIn'); + if (!req.session) { return cb(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); } + var self = this; // regenerate the session, which is good practice to help @@ -25,10 +27,6 @@ SessionManager.prototype.logIn = function(req, user, cb) { if (err) { return cb(err); } - // TODO: Error if session isn't available here. - if (!req.session) { - req.session = {}; - } if (!req.session[self._key]) { req.session[self._key] = {}; }