Skip to content

Commit

Permalink
Error if session isn't available.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed May 18, 2022
1 parent fa80b20 commit fa70e2f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/sessionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function SessionManager(options, serializeUser) {
SessionManager.prototype.logIn = function(req, user, cb) {
console.log('SM: logIn');

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

var self = this;

// regenerate the session, which is good practice to help
Expand All @@ -25,10 +27,6 @@ SessionManager.prototype.logIn = function(req, user, cb) {
if (err) {
return cb(err);
}
// TODO: Error if session isn't available here.
if (!req.session) {
req.session = {};
}
if (!req.session[self._key]) {
req.session[self._key] = {};
}
Expand Down

0 comments on commit fa70e2f

Please sign in to comment.