diff --git a/config/modules/authsome.js b/config/modules/authsome.js index 61f0d751c7cf9bca4644c8820fd072e56c109767..d07f4b5fae91511e871ec3725b0cb53257f39da6 100644 --- a/config/modules/authsome.js +++ b/config/modules/authsome.js @@ -163,7 +163,8 @@ class EditoriaMode { const permission = (await this.isAuthor(Book)) || (await this.isAssignedCopyEditor(Book)) || - (await this.isAssignedProductionEditor(Book)) + ((await this.isAssignedProductionEditor(Book)) || + (await this.isGlobalProductionEditor())) return permission } @@ -238,9 +239,13 @@ class EditoriaMode { } else { current = this.object } - const collection = { id: current.objectId } - return this.isAssignedProductionEditor(collection) + + const permissions = await this.checkTeamMembers( + ['isAssignedProductionEditor', 'isGlobalProductionEditor'], + collection, + ) + return permissions } async canCreateBook() { @@ -264,8 +269,8 @@ class EditoriaMode { team && team.objectId === collection.id, ) || false - - return foundTeam ? true : false //eslint-disable-line + const permission = foundTeam || (await this.isGlobalProductionEditor()) + return permission } async canBroadcastEvent() { @@ -851,6 +856,11 @@ module.exports = { const mode = new EditoriaMode(userId, operation, object, context) return mode.canInteractWithBooks() }, + 'can archive books': (userId, operation, object, context) => { + // DONE + const mode = new EditoriaMode(userId, operation, object, context) + return mode.canInteractWithBooks() + }, 'can delete books': (userId, operation, object, context) => { // DONE const mode = new EditoriaMode(userId, operation, object, context)