Skip to content

Commit

Permalink
Improve error message when session support isn't available.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Dec 15, 2021
1 parent 444b71a commit c2091b6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/strategies/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ util.inherits(SessionStrategy, Strategy);
* @api protected
*/
SessionStrategy.prototype.authenticate = function(req, options) {
if (!req._passport) { return this.error(new Error('passport.initialize() middleware not in use')); }
if (!req.session) { return this.error(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); }
options = options || {};

var self = this,
Expand Down
2 changes: 1 addition & 1 deletion test/strategies/session.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('SessionStrategy', function() {

it('should error', function() {
expect(error).to.be.an.instanceOf(Error);
expect(error.message).to.equal('passport.initialize() middleware not in use');
expect(error.message).to.equal('Login sessions require session support. Did you forget to use `express-session` middleware?');
});

it('should not set user on request', function() {
Expand Down

0 comments on commit c2091b6

Please sign in to comment.