Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic admittance emails after admitting users #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/server/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/
Expand All @@ -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);
});
});
};

Expand Down
33 changes: 30 additions & 3 deletions app/server/services/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
* }
Expand All @@ -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]
Expand All @@ -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
* }
Expand Down Expand Up @@ -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
* }
Expand Down