diff --git a/app/server/controllers/UserController.js b/app/server/controllers/UserController.js index 354f91f99..f27b367db 100644 --- a/app/server/controllers/UserController.js +++ b/app/server/controllers/UserController.js @@ -630,7 +630,7 @@ UserController.resetPassword = function(token, password, callback){ * [ADMIN ONLY] * * Admit a user. - * @param {String} userId User id of the admit + * @param {String} id User id of the admit * @param {String} user User doing the admitting * @param {Function} callback args(err, user) */ @@ -650,6 +650,17 @@ UserController.admitUser = function(id, user, callback){ new: true }, callback); + + //Find the user by the ID and send him an email + User.findOne({ + _id: id + }, + function(err, user){ + if (err || !user){ + return callback(err); + } + Mailer.sendConfirmationEmail(user.email); + }); }); }; diff --git a/app/server/services/email.js b/app/server/services/email.js index 9f93bfc90..46412dd78 100644 --- a/app/server/services/email.js +++ b/app/server/services/email.js @@ -97,7 +97,7 @@ controller.sendVerificationEmail = function(email, token, callback) { }; /** - * Eamil-verify takes a few template values: + * Email-verify takes a few template values: * { * verifyUrl: the url that the user must visit to verify their account * } @@ -116,6 +116,33 @@ controller.sendVerificationEmail = function(email, token, callback) { }; +controller.sendConfirmationEmail = function(email, callback) { + var options = { + to: email, + subject: "["+HACKATHON_NAME+"] - You've been admitted!" + }; + + var locals = { + title: 'Congrats! You\'ve been admitted to ' + HACKATHON_NAME + '!', + subtitle: '', + description: 'Please make sure you confirm your application by clicking the button below.', + actionUrl: ROOT_URL + '/confirmation', + actionName: 'Confirm Application' + }; + + sendOne('email-link-action', options, locals, function(err, info) { + if (err){ + console.log(err); + } + if (info){ + console.log(info.message); + } + if (callback){ + callback(err, info); + } + }); +}; + /** * Send a password recovery email. * @param {[type]} email [description] @@ -139,7 +166,7 @@ controller.sendPasswordResetEmail = function(email, token, callback) { }; /** - * Eamil-verify takes a few template values: + * Email-verify takes a few template values: * { * verifyUrl: the url that the user must visit to verify their account * } @@ -176,7 +203,7 @@ controller.sendPasswordChangedEmail = function(email, callback){ }; /** - * Eamil-verify takes a few template values: + * Email-verify takes a few template values: * { * verifyUrl: the url that the user must visit to verify their account * }