title: Function execution is stopped in the middle
body: <p>I write middleware to check user credential on each call.</p>
  
  <p>As it is meant to work: I get ID token from the user. Checking for whom was token created. If the data are correct - I save them for future use .</p>
  
  <pre><code>middleware = function(req, res, next) {
    var storage = {};
    storage.ip = req.ip;
    storage.logged = false;
    storage.username = 'Guest';
  
  
    if(req.headers.authorization) {
  
      var base64Id = req.headers.authorization.split(' ');
  
  
      try {
  
        var decoded = jwt.verify(base64Id[1], app.get('salt'));
        console.log('decoded',decoded);
  
        Token.findOne({ jti: decoded.abc }, function(err, token) {
          if (err) {
            console.log(err);
          }
  
          if(token.browser !== req.headers['user-agent'] || req.ip !== token.ip) {
            console.log('incydent: niezgodność ip lub przeglądarki');
          } else {
            User.findOne({_id: token.iss}, function(err, user) {
              if(err) {
                console.log(err);
              }
              if(user.name === decoded.name) {
                console.log('data are correct');
                storage.username = user.name;
                storage.logged = true;
              } else {
                console.log('data are wrong');
              }
            });  
  
            console.log('next step');
          }
  
        });
  
      } catch(err) {
        if(err.name === 'TokenExpiredError') {
          token.deactivate();
        } else {
          console.log('ERROR!',JSON.stringify(err,null,4))
        }
      }
  
    } 
    req.storage = storage;
    next();
  };
  </code></pre>
  
  <p>On console, my last line is 'data are correct', and line with <code>console.log('next step');</code> never has been executed. No errors are throw on console either.</p>