Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
now pass along token options
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Feb 18, 2015
1 parent 06daf73 commit 521443a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions index.js
Expand Up @@ -71,10 +71,14 @@ function MustacheMailer(opts) {
if (this.tokenFacilitator) {
Handlebars.registerHelper('tokenHelper', function(data) {
var done = this.async();
_this.tokenFacilitator.generate(data.hash, function(err, token) {
if (err) return done(err);
else return done(null, token);
});
_this.tokenFacilitator.generate(
_.omit(data.hash, ['prefix', 'ttl']),
_.pick(data.hash, ['prefix', 'ttl']),
function(err, token) {
if (err) return done(err);
else return done(null, token);
}
);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/bar.text.hbs
@@ -1,5 +1,5 @@
Hello {{fname}} glad to meet you.

http://example.com/{{{tokenHelper name=name email=email}}}
http://example.com/{{{tokenHelper name=name email=email prefix="email_confirm_" ttl=680400000}}}

-- Ben.
4 changes: 3 additions & 1 deletion test/mustache-mailer-test.js
Expand Up @@ -197,10 +197,12 @@ describe('MustacheMailer', function() {
templateDir: path.resolve(__dirname, './fixtures'),
// a fake token facilitator.
tokenFacilitator: {
generate: function(data, cb) {
generate: function(data, opts, cb) {
setTimeout(function() {
data.email.should.eql('zeke@example.com');
data.name.should.eql('Zeke');
opts.ttl.should.eql(680400000);
opts.prefix.should.eql('email_confirm_');
return cb(null, parseInt(Math.random() * 256));
}, 20);
}
Expand Down

0 comments on commit 521443a

Please sign in to comment.