From 36547a9c3aee8ddcedbbc2e76253952229b28b75 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Tue, 12 Feb 2019 23:36:42 +0100 Subject: [PATCH] Removed ghost_auth_id from Admin API v2 response refs #10438 - unused field - no need to expose this field --- .../utils/serializers/output/utils/clean.js | 73 ++++++++++--------- .../utils/serializers/output/utils/mapper.js | 4 +- core/test/acceptance/old/admin/utils.js | 1 + core/test/regression/api/v2/admin/utils.js | 1 + 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/core/server/api/v2/utils/serializers/output/utils/clean.js b/core/server/api/v2/utils/serializers/output/utils/clean.js index a10df51fc4..dfa36ee52a 100644 --- a/core/server/api/v2/utils/serializers/output/utils/clean.js +++ b/core/server/api/v2/utils/serializers/output/utils/clean.js @@ -27,43 +27,46 @@ const tag = (attrs, frame) => { return attrs; }; -const author = (attrs) => { - // Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1 - delete attrs.created_at; - delete attrs.updated_at; - delete attrs.last_seen; - delete attrs.status; +const author = (attrs, frame) => { + if (localUtils.isContentAPI(frame)) { + // Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1 + delete attrs.created_at; + delete attrs.updated_at; + delete attrs.last_seen; + delete attrs.status; + + // Extra properties removed from v2 + delete attrs.accessibility; + delete attrs.locale; + delete attrs.tour; + delete attrs.visibility; + + // We are standardising on returning null from the Content API for any empty values + if (attrs.twitter === '') { + attrs.twitter = null; + } + if (attrs.bio === '') { + attrs.bio = null; + } + if (attrs.website === '') { + attrs.website = null; + } + if (attrs.facebook === '') { + attrs.facebook = null; + } + if (attrs.meta_title === '') { + attrs.meta_title = null; + } + if (attrs.meta_description === '') { + attrs.meta_description = null; + } + if (attrs.location === '') { + attrs.location = null; + } + } + delete attrs.ghost_auth_id; - // Extra properties removed from v2 - delete attrs.accessibility; - delete attrs.locale; - delete attrs.tour; - delete attrs.visibility; - - // We are standardising on returning null from the Content API for any empty values - if (attrs.twitter === '') { - attrs.twitter = null; - } - if (attrs.bio === '') { - attrs.bio = null; - } - if (attrs.website === '') { - attrs.website = null; - } - if (attrs.facebook === '') { - attrs.facebook = null; - } - if (attrs.meta_title === '') { - attrs.meta_title = null; - } - if (attrs.meta_description === '') { - attrs.meta_description = null; - } - if (attrs.location === '') { - attrs.location = null; - } - return attrs; }; diff --git a/core/server/api/v2/utils/serializers/output/utils/mapper.js b/core/server/api/v2/utils/serializers/output/utils/mapper.js index 065650d1d4..c1d3d9965b 100644 --- a/core/server/api/v2/utils/serializers/output/utils/mapper.js +++ b/core/server/api/v2/utils/serializers/output/utils/mapper.js @@ -10,9 +10,7 @@ const mapUser = (model, frame) => { url.forUser(model.id, jsonModel); - if (utils.isContentAPI(frame)) { - clean.author(jsonModel); - } + clean.author(jsonModel, frame); return jsonModel; }; diff --git a/core/test/acceptance/old/admin/utils.js b/core/test/acceptance/old/admin/utils.js index 1a9128aeae..467e0b63a2 100644 --- a/core/test/acceptance/old/admin/utils.js +++ b/core/test/acceptance/old/admin/utils.js @@ -32,6 +32,7 @@ const expectedProperties = { .keys() .without('password') .without('ghost_auth_access_token') + .without('ghost_auth_id') , tag: _(schema.tags) .keys() diff --git a/core/test/regression/api/v2/admin/utils.js b/core/test/regression/api/v2/admin/utils.js index c8f3a8d828..1125fdef77 100644 --- a/core/test/regression/api/v2/admin/utils.js +++ b/core/test/regression/api/v2/admin/utils.js @@ -29,6 +29,7 @@ const expectedProperties = { .keys() .without('password') .without('ghost_auth_access_token') + .without('ghost_auth_id') , tag: _(schema.tags) .keys()