Skip to content

Commit

Permalink
Merge pull request #14 from adamhathcock/expose-sessionmanager
Browse files Browse the repository at this point in the history
Exposed the method to customize the SessionManager object
  • Loading branch information
rwky authored Oct 29, 2018
2 parents a6d204d + d2d88c7 commit acbe29d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,20 @@ Authenticator.prototype.session = function session(options) {
return this.authenticate('session', options);
};

// TODO: Make session manager pluggable
/*
Authenticator.prototype.sessionManager = function(mgr) {
/**
* Sets a custom SessionManager
*
* Examples:
*
* passport.sessionManager = new CustomSessionManager();
*
* @api public
*/

Authenticator.prototype.sessionManager = function sessionManager(mgr) {
this._sm = mgr;
return this;
}
*/
};

/**
* Registers a function used to serialize user objects into the session.
Expand Down
11 changes: 11 additions & 0 deletions test/authenticator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ const Authenticator = require('../lib/authenticator');


describe('Authenticator', () => {

describe('#sessionManager', () => {
it('should set custom session manager', () => {
const passport = new Authenticator();
const sessionManager = {};
passport.sessionManager(sessionManager);

expect(passport._sm).to.equal(sessionManager);
});
});

describe('#use', () => {
describe('with instance name', () => {
function Strategy() {
Expand Down

0 comments on commit acbe29d

Please sign in to comment.