title: passportjs error callback throwing exception
body: <p>I'm using LocalStrategy with MYSQL(with sequelize) which is working except when MYSQL throws exception (just to test, I shut down MYSQL server). The <code>return done(error)</code> callback throwing exception crashing server.</p>
  
  <p>Here is my piece of code:</p>
  
  <pre><code>passport.use(new LocalStrategy({usernameField: 'email', passwordField: 'password'},
      function (email, password, done) {
          db.User.find({where: {email: email}}).done(function (error, user) {
              if(error) return done(error);
  
              if (!user) return done(null, false, {message: 'unknown user'});
  
              //validate password
              if (user.password != password) {
                  return done(null, false, {message: 'invalid password'});
              }
              //all ok
              return done(null, user);
          });
      }
  ));
  </code></pre>
  
  <p>And the exception:</p>
  
  <pre><code>TypeError: Property 'next' of object #&lt;Context&gt; is not a function
      at Context.actions.error
  </code></pre>
  
  <p>What am I doing wrong? Thanks!</p>
  
  <p>EDIT:</p>
  
  <pre><code>    req._passport.instance.authenticate('local', function (err, user, info) {
          if (err) return validator.emit('exception', err);
  
          if (!user) {
              validator.result.errors.push('Username and password combination not found.');
              validator.emit('response');
          } else {
              req.login(user, function (error) {
                  if (error) return validator.emit('exception', error);
  
                  validator.emit('response');
              });
          }
      })(req, res);
  </code></pre>