Skip to content

Commit

Permalink
Enabled collections permissions in controller
Browse files Browse the repository at this point in the history
refs https://github.com/TryGhost/Team/issues/3220

- With permissions in place in the database, they can be enabled on controller level.
  • Loading branch information
naz committed Jun 9, 2023
1 parent 05bb82c commit f7e2f82
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions ghost/core/core/server/api/endpoints/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ module.exports = {
'page',
'filter'
],
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: true,
query(frame) {
return collectionsService.api.getAll(frame.options);
}
Expand All @@ -33,8 +32,7 @@ module.exports = {
data: [
'id'
],
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: true,
async query(frame) {
const model = await collectionsService.api.getById(frame.data.id);

Expand All @@ -53,8 +51,7 @@ module.exports = {
headers: {
cacheInvalidate: true
},
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: true,
async query(frame) {
return await collectionsService.api.createCollection(frame.data.collections[0]);
}
Expand All @@ -74,8 +71,7 @@ module.exports = {
}
}
},
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: true,
async query(frame) {
const model = await collectionsService.api.edit(Object.assign(frame.data.collections[0], {
id: frame.options.id
Expand All @@ -101,7 +97,6 @@ module.exports = {
},

addPost: {
docName: 'collection_posts',
statusCode: 200,
headers: {
cacheInvalidate: false
Expand All @@ -124,8 +119,9 @@ module.exports = {
}
}
},
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: {
method: 'edit'
},
async query(frame) {
const collectionPost = await collectionsService.api.addPostToCollection(frame.options.id, {
id: frame.data.posts[0].id
Expand Down Expand Up @@ -156,15 +152,13 @@ module.exports = {
}
}
},
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: true,
async query(frame) {
return await collectionsService.api.destroy(frame.options.id);
}
},

destroyPost: {
docName: 'collection_posts',
statusCode: 200,
headers: {
cacheInvalidate: true
Expand All @@ -183,8 +177,9 @@ module.exports = {
}
}
},
// @NOTE: should have permissions when moving out of Alpha
permissions: false,
permissions: {
method: 'edit'
},
async query(frame) {
const collection = await collectionsService.api.removePostFromCollection(frame.options.id, frame.options.post_id);

Expand Down

0 comments on commit f7e2f82

Please sign in to comment.