Permalink
Browse files

Added API endpoint for email signup

  • Loading branch information...
niftylettuce committed Oct 17, 2014
1 parent 092684f commit 7006780303fe8c06c140f9e7c63bb3e7178c6a48
Showing with 27 additions and 8 deletions.
  1. +20 −8 app/controllers/signup.js
  2. +7 −0 routes/api.js
View
@@ -42,14 +42,26 @@ exports = module.exports = function(settings, User) {
return next(new Error('An error has occured while registering, please try later'));
}
req.flash('success', 'Successfully signed up, check your inbox soon for a welcome email');
passport.authenticate('local', {
successReturnToOrRedirect: '/',
successFlash: true,
failureFlash: true,
failureRedirect: true
})(req, res, next);
res.format({
html: function() {
req.flash('success', 'Successfully signed up, check your inbox soon for a welcome email');
passport.authenticate('local', {
successReturnToOrRedirect: '/',
successFlash: true,
failureFlash: true,
failureRedirect: true
})(req, res, next);
},
json: function() {
res.json(user);
}
});
user.sendWelcomeEmail();
View
@@ -10,6 +10,7 @@ exports = module.exports = function(IoC, policies) {
var api = IoC.create('controllers/api');
var users = IoC.create('controllers/users');
var signup = IoC.create('controllers/signup');
var router = express.Router();
// always return JSON with our API
@@ -20,6 +21,12 @@ exports = module.exports = function(IoC, policies) {
next();
});
router.post(
'/auth/signup',
policies.ensureLoggedOut(),
signup
);
router.post(
'/auth/email',
policies.ensureLoggedOut(),

0 comments on commit 7006780

Please sign in to comment.