Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyamotodev123/3b76a7d98bbd36c12869 to your computer and use it in GitHub Desktop.
Save miyamotodev123/3b76a7d98bbd36c12869 to your computer and use it in GitHub Desktop.
app.post('/signup', function(req, res, next) {
// if email or password is missing, return an error message
if (!req.body.email || !req.body.password) {
return res.status(400).json({ error: 'Email and Password required' });
}
passport.authenticate('local-signup', function(err, user, info) {
if (err) {
return res.status(400).json(err);
}
if (user.error) {
return res.status(400).json({ error: user.error });
}
req.logIn(user, function(err) {
if (err) {
return res.status(400).json(err);
}
return res.status(200).json({ redirect: '/profile' });
});
})(req, res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment