Skip to content

Commit

Permalink
fix: dynamic format gets a ctx as a first argument as documented
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Aug 2, 2019
1 parent 4c0a40f commit f62eb4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/models/formats/dynamic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const assert = require('assert');

const instance = require('../../helpers/weak_cache');
const ctxRef = require('../ctx_ref');

const jwt = require('./jwt');
const opaque = require('./opaque');
Expand All @@ -18,7 +19,7 @@ module.exports = (provider) => {
return {
generateTokenId(...args) {
const resolver = instance(provider).dynamic[this.constructor.name];
const format = resolver(this);
const format = resolver(ctxRef.get(this), this);
assert(formats[format] && format !== 'dynamic', 'invalid format resolved');
this.format = format;
return formats[format].generateTokenId.apply(this, args);
Expand Down

0 comments on commit f62eb4b

Please sign in to comment.