Skip to content

Commit

Permalink
Add optional options to login and logout.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed May 19, 2022
1 parent 8825a9a commit e69834e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/http/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ req.logIn = function(user, options, done) {
* @api public
*/
req.logout =
req.logOut = function(done) {
req.logOut = function(options, done) {
if (typeof options == 'function') {
done = options;
options = {};
}
options = options || {};

var property = this._userProperty || 'user';

this[property] = null;
Expand Down
16 changes: 14 additions & 2 deletions lib/sessionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ function SessionManager(options, serializeUser) {
this._serializeUser = serializeUser;
}

SessionManager.prototype.logIn = function(req, user, cb) {
SessionManager.prototype.logIn = function(req, user, options, cb) {
if (typeof options == 'function') {
cb = options;
options = {};
}
options = options || {};

console.log('SM: logIn');

if (!req.session) { return cb(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); }
Expand Down Expand Up @@ -44,7 +50,13 @@ SessionManager.prototype.logIn = function(req, user, cb) {
});
}

SessionManager.prototype.logOut = function(req, cb) {
SessionManager.prototype.logOut = function(req, options, cb) {
if (typeof options == 'function') {
cb = options;
options = {};
}
options = options || {};

console.log('SM: logOut');

if (!req.session) { return cb(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); }
Expand Down

0 comments on commit e69834e

Please sign in to comment.