diff --git a/controllers/user.js b/controllers/user.js index 7c4a9dc77a..54d6c2d552 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -93,18 +93,12 @@ exports.getEmailSignup = function(req, res) { */ exports.postEmailSignup = function(req, res, next) { - console.log('post email signup called'); - req.assert('email', 'Email is not valid').isEmail(); - req.assert('password', 'Password must be at least 4 characters long').len(4); - req.assert('confirmPassword', 'Passwords do not match') - .equals(req.body.password); - var errors = req.validationErrors(); if (errors) { req.flash('errors', errors); return res.redirect('/email-signup'); - console.log(errors); + debug(errors); } var user = new User({ @@ -132,6 +126,29 @@ exports.postEmailSignup = function(req, res, next) { res.redirect('/email-signup'); }); }); + var transporter = nodemailer.createTransport({ + service: 'Mandrill', + auth: { + user: secrets.mandrill.user, + pass: secrets.mandrill.password + } + }); + var mailOptions = { + to: user.email, + from: 'Team@freecodecamp.com', + subject: 'Welcome to Free Code Camp!', + text: [ + 'Greetings from San Francisco!\n\n', + 'Thank you for joining our community.\n', + 'Feel free to email us at this address if you have any questions about Free Code Camp.\n', + "And if you have a moment, check out our blog: blog.freecodecamp.com.\n", + 'Good luck with the challenges!\n\n', + '- the Volunteer Camp Counselor Team' + ].join('') + }; + transporter.sendMail(mailOptions, function(err) { + if (err) { return err; } + }); }); }; @@ -456,9 +473,6 @@ exports.getReset = function(req, res) { */ exports.postReset = function(req, res, next) { - req.assert('password', 'Password must be at least 4 characters long.').len(4); - req.assert('confirm', 'Passwords must match.').equals(req.body.password); - var errors = req.validationErrors(); if (errors) { @@ -547,8 +561,6 @@ exports.getForgot = function(req, res) { */ exports.postForgot = function(req, res, next) { - req.assert('email', 'Please enter a valid email address.').isEmail(); - var errors = req.validationErrors(); if (errors) { diff --git a/views/account/email-signup.jade b/views/account/email-signup.jade index 3d734f2a9b..0a5f2f4687 100644 --- a/views/account/email-signup.jade +++ b/views/account/email-signup.jade @@ -48,12 +48,12 @@ block content .form-group .col-sm-6.col-sm-offset-3 input.form-control(type='password', ng-model='confirmPassword', name='confirmPassword', id='confirmPassword', placeholder='confirm password', required, ng-minlength=5) - .col-sm-6.col-sm-offset-3(ng-cloak, ng-show="(confirmPassword !== password) && !signupForm.confirmPassword.$pristine") - alert(type='danger') - span.ion-close-circled - | Passwords must match. + .col-sm-6.col-sm-offset-3(ng-cloak, ng-show="(confirmPassword !== password) && !signupForm.confirmPassword.$pristine") + alert(type='danger') + span.ion-close-circled + | Passwords must match. .form-group - .col-sm-offset-3.col-sm-6 + .col-sm-6.col-sm-offset-3 button.btn.btn-success(type='submit', ng-disabled='signupForm.$invalid') span.ion-person-add | Signup