0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added support for passing thunk for membersApi

no-issue

This is to allow support for consumers to dynamically update their
membersApi instance, for example when configuration changes, and not
have to replace the instance of members-ssr
This commit is contained in:
Fabien O'Carroll 2019-07-17 14:40:37 +08:00
parent 192f27b5bd
commit 942187f48e

View file

@ -29,6 +29,10 @@ const withBodyAndCookies = (fn, cookieConfig) => (req, res) => {
});
};
const get = (value) => {
return typeof value === 'function' ? value() : value;
};
module.exports = function create(options = EMPTY) {
if (options === EMPTY) {
throw new Error('Must pass options');
@ -56,7 +60,7 @@ module.exports = function create(options = EMPTY) {
secure: cookieSecure
};
const verifyJwt = token => membersApi.getPublicConfig().then(({publicKey, issuer}) => {
const verifyJwt = token => get(membersApi).getPublicConfig().then(({publicKey, issuer}) => {
return new Promise((resolve, reject) => {
jwt.verify(token, publicKey, {
algorithms: ['RS512'],