diff --git a/lib/sessionmanager.js b/lib/sessionmanager.js index c39bc6e5..0c43e5b3 100644 --- a/lib/sessionmanager.js +++ b/lib/sessionmanager.js @@ -47,12 +47,14 @@ SessionManager.prototype.logIn = function(req, user, cb) { SessionManager.prototype.logOut = function(req, cb) { console.log('SM: logOut'); + if (!req.session) { return cb(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); } + var self = this; // clear the user from the session object and save. // this will ensure that re-using the old session id // does not have a logged in user - if (req.session && req.session[this._key]) { + if (req.session[this._key]) { delete req.session[this._key].user; }