title: Error:400 Bad Request
body: <p><strong><code>routes.js</code></strong></p>
  
  <pre><code>//require the passport strategy from the folder in the project.
    var passport = require('passport');
    var x = require('./usefile/file');
  
  var requireLogin = passport.authenticate('local',{session: false});
  
  module.exports = function(app){
  
  var auth = express.Router();
  
  app.use('/api/auth', auth);
  
  auth.post('/login', requireLogin, function(req, res){
       x.login(req, res)});
  }
  </code></pre>
  
  <p><strong><code>passport.js</code></strong></p>
  
  <pre><code>var passport = require('passport');
  var JwtStrategy = require('passport-jwt').Strategy;
  var ExtractJwt = require('passport-jwt').ExtractJwt;
  var LocalStrategy = require('passport-local').Strategy;
  var config = require('./auth');
  var User = require('../models/user');
  
  var localOptions = {
      usernameField: 'email',
  };
  
  var localLogin = new LocalStrategy(localOptions, function (email, password, done) {
      User.find(
          { email: email }, function (err, user) {
              if (err) {
                  return done(err);
              }
              if (!user) {
                  return done(null, false, { error: 'Login failed,Please try again.' });
              }
              if (!isMatch) {
                  return done(null, false, { error: 'Login failed, Please try again.' });
              }
              user.comparePassword(function(password, isMatch){
                  if(err){
                      return done(err);
                  }
                  if(!isMatch){
                      return done(null, false, {error:'Login failed, Please try again.'});
                  }
                  return done(null, user);
              });
          });
  });
  passport.use(localLogin);
  </code></pre>
  
  <p>Note: My code is not using the <code>requireLogin</code> which is used to authenticate from the passport, So it is showing 400 bad request error.</p>
  
  <p>I have referred API docs of passport-local there I found:</p>
  
  <pre><code>    app.post('/login', 
        passport.authenticate('local', { failureRedirect: '/login' }),
        function(req, res) {
          res.redirect('/');
        });
  </code></pre>
  
  <p>Here <code>failureRedirect: '/login'</code> What does it mean? </p>
  
  <p>Please help.</p>