diff --git a/lib/http/request.js b/lib/http/request.js index 34a26619..0206abb8 100644 --- a/lib/http/request.js +++ b/lib/http/request.js @@ -69,8 +69,8 @@ req.logOut = function() { } this[property] = null; - if (this._passport && this._passport.session) { - delete this._passport.session.user; + if (this._passport) { + this._passport.instance._sm.logOut(this); } }; diff --git a/lib/sessionmanager.js b/lib/sessionmanager.js index 8c524e24..6219c689 100644 --- a/lib/sessionmanager.js +++ b/lib/sessionmanager.js @@ -28,5 +28,12 @@ SessionManager.prototype.logIn = function(req, user, cb) { }); } +SessionManager.prototype.logOut = function(req, cb) { + if (req._passport && req._passport.session) { + delete req._passport.session.user; + } + cb && cb(); +} + module.exports = SessionManager;