Wednesday 24 May 2017

Ajax call to passport does not run the authenticate function

I do not want a redirect in my sign-up route, it is a two stage process (the way I currently have it figured out), so I would like to submit the first form, save to db with ajax and return something, and then show the second form to complete sign up. The post route works, but the function does not run

router.route('/register')
  .post((req, res, next) => {
      console.log('this bit here works');
    passport.authenticate('local-signup', function(error, user) {
      console.log('it's here that nothing happens');
    if(error) {
      return res.status(500).json(error);
    }
      return res.json(user); //this is what I want to return;
  })
})

Does passport only work with the one post call?



via lockykeaney

No comments:

Post a Comment