You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serializer throws this error (plone.api.exc.InvalidParameterError: Cannot find a permission with name 'collective.easyform.DownloadSavedInput') when you try to retrieve an Easyform via the REST-API with an unauthenticated user or as an user who does not have this permission.
Reproduce
Setup Plone 6.x and collective.easyform 4.2.0
Create easyform named my-easyform & publish
Retrieve it via REST-API (curl -i -X GET http://localhost:8080/Plone/my-easyform -H "Accept: application/json")
Possible solutions
Variant A
Wrap if api.user.has_permission(DOWNLOAD_SAVED_PERMISSION, obj=self.context): in serializer.py into a try-except-block. If the InvalidParameterError exception is thrown, we know the user does not have this permission.
Variant B
Instead of using 'collective.easyform.DownloadSavedInput' (via DOWNLOAD_SAVED_PERMISSION) we can use 'collective.easyform: Download Saved Input'. For reasons I dont understand this solves the issue:
if api.user.has_permission('collective.easyform: Download Saved Input', obj=self.context):
The text was updated successfully, but these errors were encountered:
Each permission has an id (collective.easyform.DownloadSavedInput) and a title (collective.easyform: Download Saved Input). plone.api.user.has_permission checks the permission in a way that uses the title. So probably variant B is the better solution.
Serializer throws this error (
plone.api.exc.InvalidParameterError: Cannot find a permission with name 'collective.easyform.DownloadSavedInput'
) when you try to retrieve an Easyform via the REST-API with an unauthenticated user or as an user who does not have this permission.Reproduce
my-easyform
& publishcurl -i -X GET http://localhost:8080/Plone/my-easyform -H "Accept: application/json"
)Possible solutions
Variant A
Wrap
if api.user.has_permission(DOWNLOAD_SAVED_PERMISSION, obj=self.context):
inserializer.py
into a try-except-block. If theInvalidParameterError
exception is thrown, we know the user does not have this permission.Variant B
Instead of using
'collective.easyform.DownloadSavedInput'
(viaDOWNLOAD_SAVED_PERMISSION
) we can use'collective.easyform: Download Saved Input'
. For reasons I dont understand this solves the issue:The text was updated successfully, but these errors were encountered: