fixed changes to api

This commit is contained in:
Wyatt Johnson
2018-02-16 15:26:18 -07:00
parent e71bcbe58d
commit d86ff8418d
2 changed files with 15 additions and 7 deletions
+12 -6
View File
@@ -1,5 +1,5 @@
const jwt = require('jsonwebtoken');
const uniq = require('lodash/uniq');
const { merge, uniq, omitBy, isUndefined } = require('lodash');
/**
* MultiSecret will take many secrets and provide a unified interface for
@@ -22,7 +22,10 @@ class MultiSecret {
* Sign will sign with the first secret.
*/
sign(payload, options) {
return this.secrets[0].sign(payload, options);
return this.secrets[0].sign(
omitBy(payload, isUndefined),
omitBy(options, isUndefined)
);
}
/**
@@ -78,10 +81,13 @@ class Secret {
return jwt.sign(
payload,
this.signingKey,
Object.assign({}, options, {
keyid: this.kid,
algorithm: this.algorithm,
})
omitBy(
merge({}, options, {
keyid: this.kid,
algorithm: this.algorithm,
}),
isUndefined
)
);
}
+3 -1
View File
@@ -27,7 +27,9 @@ module.exports = class TokenService {
pat: true,
};
set(payload, JWT_USER_ID_CLAIM, userID);
if (userID) {
set(payload, JWT_USER_ID_CLAIM, userID);
}
// Sign the payload.
const jwt = JWT_SECRET.sign(payload, {});