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>
|
<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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
49
src/user.js
49
src/user.js
@@ -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
|
|
||||||
}),
|
|
||||||
reset_email_plaintext = global.templates['emails/reset_plaintext'].parse({
|
|
||||||
'RESET_LINK': reset_link
|
|
||||||
});
|
|
||||||
|
|
||||||
var message = emailjs.message.create({
|
Emailer.send('reset', uid, {
|
||||||
text: reset_email_plaintext,
|
'site_title': (meta.config['title'] || 'NodeBB'),
|
||||||
from: meta.config['email:from'] ? meta.config['email:from'] : 'localhost@example.org',
|
'reset_link': reset_link,
|
||||||
to: email,
|
|
||||||
subject: 'Password Reset Requested',
|
subject: 'Password Reset Requested - ' + (meta.config['title'] || 'NodeBB') + '!',
|
||||||
attachment: [{
|
template: 'reset',
|
||||||
data: reset_email,
|
uid: uid
|
||||||
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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user