mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
4b57ad33b0
refs https://github.com/TryGhost/Ghost/pull/11499 - Removed unused and confusin isPaymentConfigured because it was basing it's logic on old `isPaid` flag. Having it in the codebase was adding confusion. - `isPaid` config flag still needs a proper cleanup with a migration etc. - Added little post PR merge cleanup
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
const MembersSSR = require('@tryghost/members-ssr');
|
|
|
|
const createMembersApiInstance = require('./api');
|
|
const common = require('../../lib/common');
|
|
const urlUtils = require('../../lib/url-utils');
|
|
const settingsCache = require('../settings/cache');
|
|
|
|
let membersApi;
|
|
|
|
// Bind to events to automatically keep subscription info up-to-date from settings
|
|
common.events.on('settings.edited', function updateSettingFromModel(settingModel) {
|
|
if (!['members_subscription_settings'].includes(settingModel.get('key'))) {
|
|
return;
|
|
}
|
|
|
|
const reconfiguredMembersAPI = createMembersApiInstance();
|
|
reconfiguredMembersAPI.bus.on('ready', function () {
|
|
membersApi = reconfiguredMembersAPI;
|
|
});
|
|
reconfiguredMembersAPI.bus.on('error', function (err) {
|
|
common.logging.error(err);
|
|
});
|
|
});
|
|
|
|
const membersService = {
|
|
contentGating: require('./content-gating'),
|
|
|
|
config: require('./config'),
|
|
|
|
get api() {
|
|
if (!membersApi) {
|
|
membersApi = createMembersApiInstance();
|
|
|
|
membersApi.bus.on('error', function (err) {
|
|
common.logging.error(err);
|
|
});
|
|
}
|
|
return membersApi;
|
|
},
|
|
|
|
ssr: MembersSSR({
|
|
cookieSecure: urlUtils.isSSL(urlUtils.getSiteUrl()),
|
|
cookieKeys: [settingsCache.get('theme_session_secret')],
|
|
cookieName: 'ghost-members-ssr',
|
|
cookieCacheName: 'ghost-members-ssr-cache',
|
|
getMembersApi: () => membersService.api
|
|
})
|
|
};
|
|
|
|
module.exports = membersService;
|
|
module.exports.middleware = require('./middleware');
|