Commit 424fc8a4 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

MLAB-129: add welcome email after successful verification

parent e7931881
...@@ -80,6 +80,19 @@ var methods = { ...@@ -80,6 +80,19 @@ var methods = {
} }
callback(user, err); callback(user, err);
}); });
},
getUserById: function(userId, callback) {
dbconn.user.query('SELECT verificationStatus, email, salutation, title, firstname, lastname, industry, organisation, speciality FROM user WHERE id = ' +userId, function (err, rows, fields) {
if (err) {
throw err;
}
else {
if ( rows.length > 0) {
user = rows[0];
}
}
callback(user, err);
});
}, },
checkUserEmail: function(email, callback) { checkUserEmail: function(email, callback) {
let user let user
......
...@@ -581,9 +581,8 @@ module.exports = function (app, config, passport, i18n) { ...@@ -581,9 +581,8 @@ module.exports = function (app, config, passport, i18n) {
// ============= USER VERIFICATION ================================ // ============= USER VERIFICATION ================================
app.get("/verifyAccount", function(req, res){ app.get("/verifyAccount", function(req, res){
console.log(req.query)
methods.getUserIdByVerificationToken(req.query.token, function(userId, err){ methods.getUserIdByVerificationToken(req.query.token, function(userId, err){
console.log(err)
console.log(userId)
if (userId) { if (userId) {
let userData = { let userData = {
id: userId, id: userId,
...@@ -597,6 +596,30 @@ module.exports = function (app, config, passport, i18n) { ...@@ -597,6 +596,30 @@ module.exports = function (app, config, passport, i18n) {
}); });
} }
else { else {
// send welcome email after successful account verification
methods.getUserById(userId, function(data, err){
if (err) {
console.log("Error: "+err)
}
else {
// send email
var emailSubject = "Herzlich willkommen"
var emailContent = "Lieber Nutzer,\n\n"+
"herzlich willkommen beim Transferportal der HFT Stuttgart!\n"+
"Sie können nun alle Dienste des Portals nutzen.\n\n"+mailSignature
mailer.options.to = data.email;
mailer.options.subject = emailSubject;
mailer.options.text = emailContent;
mailer.transport.sendMail(mailer.options, function(err) {
if (err) {
console.log('cannot send email')
throw err
}
})
}
})
res.render(lang+'/account/verification', { res.render(lang+'/account/verification', {
status: true status: true
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment