Skip to content

Commit

Permalink
Don't set req._passport.sesison in initialize middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Sep 23, 2021
1 parent 6861724 commit 7f41957
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
5 changes: 0 additions & 5 deletions lib/middleware/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ module.exports = function initialize(passport) {
req._passport = {};
req._passport.instance = passport;

if (req.session && req.session[passport._key]) {
// load data from existing session
req._passport.session = req.session[passport._key];
}

next();
};
};
20 changes: 0 additions & 20 deletions test/middleware/initialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ describe('middleware/initialize', function() {
expect(request._passport.instance).to.be.an.instanceOf(Passport);
expect(request._passport.instance).to.equal(passport);
});

it('should not expose empty object as session storage on internal request property', function() {
expect(request._passport.session).to.be.undefined;
});
});

describe('handling a request with a new session', function() {
Expand Down Expand Up @@ -74,10 +70,6 @@ describe('middleware/initialize', function() {
expect(request._passport.instance).to.be.an.instanceOf(Passport);
expect(request._passport.instance).to.equal(passport);
});

it('should not expose session storage on internal request property', function() {
expect(request._passport.session).to.be.undefined;
});
});

describe('handling a request with an existing session', function() {
Expand Down Expand Up @@ -115,12 +107,6 @@ describe('middleware/initialize', function() {
expect(request._passport.instance).to.be.an.instanceOf(Passport);
expect(request._passport.instance).to.equal(passport);
});

it('should expose session storage on internal request property', function() {
expect(request._passport.session).to.be.an('object');
expect(Object.keys(request._passport.session)).to.have.length(1);
expect(request._passport.session.user).to.equal('123456');
});
});

describe('handling a request with an existing session using custom session key', function() {
Expand Down Expand Up @@ -159,12 +145,6 @@ describe('middleware/initialize', function() {
expect(request._passport.instance).to.be.an.instanceOf(Passport);
expect(request._passport.instance).to.equal(passport);
});

it('should expose session storage on internal request property', function() {
expect(request._passport.session).to.be.an('object');
expect(Object.keys(request._passport.session)).to.have.length(1);
expect(request._passport.session.user).to.equal('123456');
});
});

});

0 comments on commit 7f41957

Please sign in to comment.