-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes missing identity value in token when it's not a string #484
Fixes missing identity value in token when it's not a string #484
Conversation
…sToken constuctor
lib/jwt/AccessToken.js
Outdated
@@ -212,6 +212,7 @@ function AccessToken(accountSid, keySid, secret, options) { | |||
if (!keySid) { throw new Error('keySid is required'); } | |||
if (!secret) { throw new Error('secret is required'); } | |||
options = options || {}; | |||
if (_.isInteger(options.identity)) { options.identity = new String(options.identity); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather fix the check on line 252 below. Could it just be grants.identity = String(this.identity);
?
@childish-sambino yes makes sense to move it there. I left the original conditional statement checking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lib/jwt/AccessToken.js
Outdated
@@ -249,7 +249,7 @@ _.extend(AccessToken.prototype, { | |||
} | |||
|
|||
var grants = {}; | |||
if (_.isString(this.identity)) { grants.identity = this.identity; } | |||
if (_.isInteger(this.identity) || _.isString(this.identity)) { grants.identity = String(this.identity); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Trailing semicolon not needed.
Fixes #438
Resolves missing identity value in token when it's not a string begin passed in the
AccessToken
constructor.The specs of the issue ticket suggest throwing an error when identity is passed as an integer. Originally, I took this approach but I quickly realized this would cause breaking changes for anyone passing numeric values in identity option. I do not believe this is error worthy because simple converting the value to a string solves the down stream implication in the jwt.
Contributing to Twilio