mirror of
https://github.com/wassname/talk.git
synced 2026-07-12 10:42:30 +08:00
fixed changes to api
This commit is contained in:
+12
-6
@@ -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
@@ -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, {});
|
||||
|
||||
Reference in New Issue
Block a user