title: Why doesn't my custom callback in Passport JS work?
body: <p>I'm trying to get the user to be able to sign up to my website, and store the credentials on mongodb.</p>
  
  <p>This is my auth.js file, where the route is defined:</p>
  
  <pre><code>router.post('/signup', (req,res,next) =&gt; {
      Passport.authenticate('local-signup', err =&gt; {
      if (err) {
          if (err.name === "MongoError" &amp;&amp; err.code === 11000) {
              res.status(409).json({
                  success: false,
                  message: "Unsuccessful",
                  errors: {
                      email: "This email is already taken."
                  }
              });
          }
          res.status(400).json({
              success: false,
              message: "Unsuccessful",
              errors: {
                  unknown: "Could not process for some reason. Contact admin."
              }
          });
      }        
      res.status(200).json({
          success: true,
          message: "Successful",
          errors: {}
      });
  }) (res, req, next);
  }
  </code></pre>
  
  <p>That last bracket got a bit messed up but believe me, it's not a syntax error. 
  This snippet is where I have defined the passport strategy:</p>
  
  <pre><code>require ('../Models/Users')
  const mongoose = require('mongoose');
  mongoose.connect('mongodb://localhost/onlinestore');
  const User = mongoose.model('User');
  const PassportLocalStrategy = require('passport-local').Strategy;
  const Passport = require('passport');
  
  module.exports = Passport.use(new PassportLocalStrategy({
          usernameField: 'email',
          passwordField: 'password',
          session: false,
          passReqToCallback: true,
      }, (email, password, done) =&gt; {              
          let user = new User();
          user.email = email.trim();
          user.password = password.trim();
          user.save(err =&gt; {
              if (err) {
                  console.log(err);
                  return done(err);
              } else {
                  console.log("Success");
                  return done(null);
              }
          });
      }
  ));
  </code></pre>
  
  <p>The route is able to get the user inputted password and user. When I click submit, literally nothing happens; the server doesn't console anything nor does the client. After a bit of debugging I think the issue is due to the fact that Passport.Authenticate is not being called but I'm not sure why. I can post other code snippets if necessary, thanks!</p>