mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
tweaks to emailer, implemented emailer hook for password reset
This commit is contained in:
20
public/templates/emails/reset.hbs
Normal file
20
public/templates/emails/reset.hbs
Normal file
@@ -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>
|
||||
Hello {{username}},
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Thank you for registering with {{site_title}}!</strong>
|
||||
</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:
|
||||
</p>
|
||||
|
||||
<blockquote>
|
||||
{{confirm_link}}
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
Thanks!<br />
|
||||
<strong>{{site_title}}</strong>
|
||||
|
||||
@@ -62,7 +62,10 @@ Emailer.send = function(template, uid, params) {
|
||||
from: Meta.config['email:from'] || 'no-reply@localhost.lan',
|
||||
subject: params.subject,
|
||||
html: results.html,
|
||||
plaintext: results.plaintext
|
||||
plaintext: results.plaintext,
|
||||
|
||||
template: template,
|
||||
uid: uid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
43
src/user.js
43
src/user.js
@@ -755,40 +755,22 @@ var bcrypt = require('bcrypt'),
|
||||
db.setObjectField('reset:uid', reset_code, uid);
|
||||
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,
|
||||
reset_email = global.templates['emails/reset'].parse({
|
||||
'RESET_LINK': reset_link
|
||||
}),
|
||||
reset_email_plaintext = global.templates['emails/reset_plaintext'].parse({
|
||||
'RESET_LINK': reset_link
|
||||
var reset_link = nconf.get('url') + 'reset/' + reset_code;
|
||||
|
||||
Emailer.send('reset', uid, {
|
||||
'site_title': (meta.config['title'] || 'NodeBB'),
|
||||
'reset_link': reset_link,
|
||||
|
||||
subject: 'Password Reset Requested - ' + (meta.config['title'] || 'NodeBB') + '!',
|
||||
template: 'reset',
|
||||
uid: uid
|
||||
});
|
||||
|
||||
var message = emailjs.message.create({
|
||||
text: reset_email_plaintext,
|
||||
from: meta.config['email:from'] ? meta.config['email:from'] : 'localhost@example.org',
|
||||
to: email,
|
||||
subject: 'Password Reset Requested',
|
||||
attachment: [{
|
||||
data: reset_email,
|
||||
alternative: true
|
||||
}]
|
||||
});
|
||||
|
||||
emailjsServer.send(message, function(err, success) {
|
||||
if (err === null) {
|
||||
socket.emit('user.send_reset', {
|
||||
status: "ok",
|
||||
message: "code-sent",
|
||||
email: email
|
||||
});
|
||||
} else {
|
||||
socket.emit('user.send_reset', {
|
||||
status: "error",
|
||||
message: "send-failed"
|
||||
});
|
||||
winston.err(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
socket.emit('user.send_reset', {
|
||||
status: "error",
|
||||
@@ -853,9 +835,12 @@ var bcrypt = require('bcrypt'),
|
||||
User.getUserField(uid, 'username', function(err, username) {
|
||||
Emailer.send('welcome', uid, {
|
||||
'site_title': (meta.config['title'] || 'NodeBB'),
|
||||
subject: 'Welcome to ' + (meta.config['title'] || 'NodeBB') + '!',
|
||||
username: username,
|
||||
'confirm_link': confirm_link
|
||||
'confirm_link': confirm_link,
|
||||
|
||||
subject: 'Welcome to ' + (meta.config['title'] || 'NodeBB') + '!',
|
||||
template: 'welcome',
|
||||
uid: uid
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user