mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
9dd7aff9c6
no-issue * Refactored hideMembersOnlyContent to 3 "stages" * Exported paymentConfigured flag from members service * Updated Content-API to check members service for paymentConfigured * Updated members content output serializer to remove content if plan required and no plan * Updated isContentAPI method * Moved api util test
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
module.exports = {
|
|
get permissions() {
|
|
return require('./permissions');
|
|
},
|
|
|
|
get serializers() {
|
|
return require('./serializers');
|
|
},
|
|
|
|
get validators() {
|
|
return require('./validators');
|
|
},
|
|
|
|
/**
|
|
* TODO: We need to check for public context as permission stage overrides
|
|
* the whole context object currently: https://github.com/TryGhost/Ghost/issues/10099
|
|
*/
|
|
isContentAPI: (frame) => {
|
|
const context = frame.options && frame.options.context || {};
|
|
// CASE: An empty context is considered public by the core/server/services/permissions/parse-context.js
|
|
// module, replicated here because the context is unparsed until after the permissions layer of the pipeline
|
|
const isPublic = context.public || Object.keys(context).length === 0;
|
|
|
|
// CASE: apiType = 'content' for HTTP Content API
|
|
return frame.apiType === 'content' || isPublic;
|
|
},
|
|
|
|
isAdminAPIKey: (frame) => {
|
|
return frame.options.context && Object.keys(frame.options.context).length !== 0 && frame.options.context.api_key &&
|
|
frame.options.context.api_key.type === 'admin';
|
|
}
|
|
};
|