tweaks to emailer, implemented emailer hook for password reset

v1.18.x
Julian Lam 11 years ago
parent 0ac9ec6001
commit 11ed9e8c85

@ -0,0 +1,20 @@
<p>
Hello,
</p>
<p>
We received a request to reset your password, possibly because you have forgotten it. If this is not the case, please ignore this email.
</p>
<p>
To continue with the password reset, please click on the following link:
</p>
<blockquote>
{{reset_link}}
</blockquote>
<p>
Thanks!<br />
<strong>{{site_title}}</strong>
</p>

@ -1,5 +0,0 @@
<p>Hello,</p>
<p>We received a request to reset your password, possibly because you have forgotten it. If this is not the case, please ignore this email.</p>
<p>To continue with the password reset, please click on the following link:</p>
<blockquote>{RESET_LINK}</blockquote>
<p>Thanks!<br /><strong>NodeBB</strong>

@ -1,15 +1,19 @@
<p> <p>
Hello {{username}}, Hello {{username}},
</p> </p>
<p> <p>
<strong>Thank you for registering with {{site_title}}!</strong> <strong>Thank you for registering with {{site_title}}!</strong>
</p> </p>
<p> <p>
To fully activate your account, we need to verify that you own the email address you registered with. Please click on the following link: To fully activate your account, we need to verify that you own the email address you registered with. Please click on the following link:
</p> </p>
<blockquote> <blockquote>
{{confirm_link}} {{confirm_link}}
</blockquote> </blockquote>
<p> <p>
Thanks!<br /> Thanks!<br />
<strong>{{site_title}}</strong> <strong>{{site_title}}</strong>

@ -62,7 +62,10 @@ Emailer.send = function(template, uid, params) {
from: Meta.config['email:from'] || 'no-reply@localhost.lan', from: Meta.config['email:from'] || 'no-reply@localhost.lan',
subject: params.subject, subject: params.subject,
html: results.html, html: results.html,
plaintext: results.plaintext plaintext: results.plaintext,
template: template,
uid: uid
}); });
} }
}); });

@ -755,39 +755,21 @@ var bcrypt = require('bcrypt'),
db.setObjectField('reset:uid', reset_code, uid); db.setObjectField('reset:uid', reset_code, uid);
db.setObjectField('reset:expiry', reset_code, (60 * 60) + new Date() / 1000 | 0); // Active for one hour db.setObjectField('reset:expiry', reset_code, (60 * 60) + new Date() / 1000 | 0); // Active for one hour
var reset_link = nconf.get('url') + 'reset/' + reset_code, var reset_link = nconf.get('url') + 'reset/' + reset_code;
reset_email = global.templates['emails/reset'].parse({
'RESET_LINK': reset_link Emailer.send('reset', uid, {
}), 'site_title': (meta.config['title'] || 'NodeBB'),
reset_email_plaintext = global.templates['emails/reset_plaintext'].parse({ 'reset_link': reset_link,
'RESET_LINK': reset_link
});
var message = emailjs.message.create({ subject: 'Password Reset Requested - ' + (meta.config['title'] || 'NodeBB') + '!',
text: reset_email_plaintext, template: 'reset',
from: meta.config['email:from'] ? meta.config['email:from'] : 'localhost@example.org', uid: uid
to: email,
subject: 'Password Reset Requested',
attachment: [{
data: reset_email,
alternative: true
}]
}); });
emailjsServer.send(message, function(err, success) { socket.emit('user.send_reset', {
if (err === null) { status: "ok",
socket.emit('user.send_reset', { message: "code-sent",
status: "ok", email: email
message: "code-sent",
email: email
});
} else {
socket.emit('user.send_reset', {
status: "error",
message: "send-failed"
});
winston.err(err);
}
}); });
} else { } else {
socket.emit('user.send_reset', { socket.emit('user.send_reset', {
@ -853,9 +835,12 @@ var bcrypt = require('bcrypt'),
User.getUserField(uid, 'username', function(err, username) { User.getUserField(uid, 'username', function(err, username) {
Emailer.send('welcome', uid, { Emailer.send('welcome', uid, {
'site_title': (meta.config['title'] || 'NodeBB'), 'site_title': (meta.config['title'] || 'NodeBB'),
subject: 'Welcome to ' + (meta.config['title'] || 'NodeBB') + '!',
username: username, username: username,
'confirm_link': confirm_link 'confirm_link': confirm_link,
subject: 'Welcome to ' + (meta.config['title'] || 'NodeBB') + '!',
template: 'welcome',
uid: uid
}); });
}); });
}); });

Loading…
Cancel
Save