User: custom email headers in verify
This commit is contained in:
parent
03b3c3cda4
commit
4098bec2c6
|
@ -283,9 +283,10 @@ User.prototype.verify = function(options, fn) {
|
||||||
from: options.from,
|
from: options.from,
|
||||||
subject: options.subject || 'Thanks for Registering',
|
subject: options.subject || 'Thanks for Registering',
|
||||||
text: options.text,
|
text: options.text,
|
||||||
html: template(options)
|
html: template(options),
|
||||||
}, function(err, email) {
|
headers: options.headers || {}
|
||||||
if (err) {
|
}, function (err, email) {
|
||||||
|
if(err) {
|
||||||
fn(err);
|
fn(err);
|
||||||
} else {
|
} else {
|
||||||
fn(null, {email: email, token: user.verificationToken, uid: user.id});
|
fn(null, {email: email, token: user.verificationToken, uid: user.id});
|
||||||
|
|
|
@ -487,6 +487,38 @@ describe('User', function(){
|
||||||
if(err) return done(err);
|
if(err) return done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Verify a user\'s email address with custom header', function(done) {
|
||||||
|
User.afterRemote('create', function(ctx, user, next) {
|
||||||
|
assert(user, 'afterRemote should include result');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
type: 'email',
|
||||||
|
to: user.email,
|
||||||
|
from: 'noreply@myapp.org',
|
||||||
|
redirect: '/',
|
||||||
|
protocol: ctx.req.protocol,
|
||||||
|
host: ctx.req.get('host'),
|
||||||
|
headers: {'message-id':'custom-header-value'}
|
||||||
|
};
|
||||||
|
|
||||||
|
user.verify(options, function (err, result) {
|
||||||
|
assert(result.email);
|
||||||
|
assert.equal(result.email.messageId, 'custom-header-value');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
request(app)
|
||||||
|
.post('/users')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect(200)
|
||||||
|
.send({email: 'bar@bat.com', password: 'bar'})
|
||||||
|
.end(function(err, res){
|
||||||
|
if(err) return done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('User.confirm(options, fn)', function () {
|
describe('User.confirm(options, fn)', function () {
|
||||||
|
|
Loading…
Reference in New Issue