Instead of doing:
app.post('/signup', passport.authenticate('local-signup', {
successRedirect : '/profile', // redirect to the secure profile section
failureRedirect : '/signup', // redirect back to the signup page if there is an error
}));
You can do something like:
app.post('/signup', function(req, res, next) {
passport.authenticate('local-signup', function(err, user, info) {
if (err) {
return next(err); // will generate a 500 error
}
// Generate a JSON response reflecting signup
if (! user) {
return res.send({ success : false, message : 'signupfailed' });
}
return res.send({ success : true, message : 'signup succeeded' });
})(req, res, next);
});
For more details go to http://passportjs.org/guide/authenticate/ and look at the Custom Callback section at the bottom.