Skip to content
Snippets Groups Projects
Commit 4a702826 authored by Mihail Hagiu's avatar Mihail Hagiu
Browse files

fix(authsome-mode): Bugfixes

parent d630804b
No related branches found
No related tags found
3 merge requests!222Sprint #26,!217Sprint #26,!195feat(authsome-mode): Added rule for PATCH collection
...@@ -335,11 +335,25 @@ async function applyAdminPolicy(user, operation, object, context) { ...@@ -335,11 +335,25 @@ async function applyAdminPolicy(user, operation, object, context) {
} }
} }
if (operation === 'PATCH') { if (operation === 'PATCH') {
if (get(object, 'current.type') === 'collection') {
return !isCollectionInStatuses(get(object, 'current'), [
'rejected',
'accepted',
'withdrawn',
])
}
if (get(object, 'current.type') === 'fragment') { if (get(object, 'current.type') === 'fragment') {
const collection = await context.models.Collection.find( const collection = await context.models.Collection.find(
get(object, 'current.collectionId'), get(object, 'current.collectionId'),
) )
return helpers.isLastFragment(collection, get(object, 'current')) return (
helpers.isLastFragment(collection, get(object, 'current')) &&
!isCollectionInStatuses(collection, [
'rejected',
'accepted',
'withdrawn',
])
)
} }
} }
return true return true
...@@ -396,6 +410,9 @@ async function applyEditorInChiefPolicy(user, operation, object, context) { ...@@ -396,6 +410,9 @@ async function applyEditorInChiefPolicy(user, operation, object, context) {
} }
} }
if (operation === 'PATCH') { if (operation === 'PATCH') {
if (get(object, 'current.type') === 'collection') {
return false
}
if (get(object, 'current.type') === 'fragment') { if (get(object, 'current.type') === 'fragment') {
return false return false
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment