mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Fixed frame context being empty
no issue
This commit is contained in:
parent
514eb22077
commit
22911b5812
2 changed files with 19 additions and 2 deletions
|
@ -6,7 +6,14 @@ module.exports = {
|
||||||
browse(apiConfig, frame) {
|
browse(apiConfig, frame) {
|
||||||
debug('browse');
|
debug('browse');
|
||||||
|
|
||||||
if (!_.get(frame, 'options.context.user') && _.get(frame, 'options.context.api_key_id')) {
|
// @TODO: `api_key_id` does not work long term, because it can be either a content or an admin api key?
|
||||||
|
/**
|
||||||
|
* ## current cases:
|
||||||
|
* - context object is empty (functional call, content api access)
|
||||||
|
* - api_key_id exists? content api access
|
||||||
|
* - user exists? admin api access
|
||||||
|
*/
|
||||||
|
if (Object.keys(frame.options.context).length === 0 || (!frame.options.context.user && frame.options.context.api_key_id)) {
|
||||||
// CASE: the content api endpoints for posts should only return non page type resources
|
// CASE: the content api endpoints for posts should only return non page type resources
|
||||||
if (frame.options.filter) {
|
if (frame.options.filter) {
|
||||||
if (frame.options.filter.match(/page:\w+\+?/)) {
|
if (frame.options.filter.match(/page:\w+\+?/)) {
|
||||||
|
@ -29,7 +36,14 @@ module.exports = {
|
||||||
read(apiConfig, frame) {
|
read(apiConfig, frame) {
|
||||||
debug('read');
|
debug('read');
|
||||||
|
|
||||||
if (!_.get(frame, 'options.context.user') && _.get(frame, 'options.context.api_key_id')) {
|
// @TODO: `api_key_id` does not work long term, because it can be either a content or an admin api key?
|
||||||
|
/**
|
||||||
|
* ## current cases:
|
||||||
|
* - context object is empty (functional call, content api access)
|
||||||
|
* - api_key_id exists? content api access
|
||||||
|
* - user exists? admin api access
|
||||||
|
*/
|
||||||
|
if (Object.keys(frame.options.context).length === 0 || (!frame.options.context.user && frame.options.context.api_key_id)) {
|
||||||
frame.data.page = false;
|
frame.data.page = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ describe('Unit: v2/utils/serializers/input/posts', function () {
|
||||||
const apiConfig = {};
|
const apiConfig = {};
|
||||||
const frame = {
|
const frame = {
|
||||||
options: {
|
options: {
|
||||||
|
context: {
|
||||||
|
user: 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue