Skip to content

Commit 4d41c67

Browse files
committed
Remove "options.template" from Email payload
Fix User.confirm to exclude "options.template" when sending the confirmation email. Certain nodemailer transport plugins are rejecting such requests.
1 parent 956f035 commit 4d41c67

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

common/models/user.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ module.exports = function(User) {
469469
function setHtmlContentAndSend(html) {
470470
options.html = html;
471471

472+
// Remove options.template to prevent rejection by certain
473+
// nodemailer transport plugins.
474+
delete options.template;
475+
472476
Email.send(options, function(err, email) {
473477
if (err) {
474478
fn(err);

test/user.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,24 @@ describe('User', function() {
16591659
done();
16601660
});
16611661
});
1662+
1663+
it('removes "options.template" from Email payload', function() {
1664+
var MailerMock = {
1665+
send: function(options, cb) { cb(null, options); },
1666+
};
1667+
1668+
return User.create({email: '[email protected]', password: 'pass'})
1669+
.then(function(user) {
1670+
return user.verify({
1671+
type: 'email',
1672+
1673+
mailer: MailerMock,
1674+
});
1675+
})
1676+
.then(function(result) {
1677+
expect(result.email).to.not.have.property('template');
1678+
});
1679+
});
16621680
});
16631681

16641682
describe('User.confirm(options, fn)', function() {

0 commit comments

Comments
 (0)