-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 9.10-HF10
-
Component/s: Rest API
- in Studio create a document type mydoctype
- in the edit layout add the following:
<nuxeo-connection id="myconn" user="{{currentUser}}"></nuxeo-connection> <dom-if if="[[_hasPermission(document, 'ReadWrite')]]"> <template> aaaa </template> </dom-if>
- add the following function in the Polymer script section:
, _hasPermission(document, perm) { const permissions = this.document && this.document.contextParameters && this.document.contextParameters.permissions; console.log(permissions); console.log(this.currentUser); return permissions && permissions.indexOf(perm) !== -1; }
- synch the project the project with the server
- create a document of type mydoctype
- create a user named robert
- give ReadWrite permission to user robert using the UI
- give WriteSecurity permission to user robert using the following curl (adapt it to match the document id of your environment):
curl -s -u Administrator:Administrator -X POST -H 'Content-Type: application/json' -d '{"params":{"username":"robert","email":null,"permission":"WriteSecurity","begin":null,"end":null,"notify":false,"comment":""},"context":{},"input":"41e40a83-8afc-4903-ae9c-280facc1818b"}' http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission
- refresh the UI
- double-check the WriteSecurity permission is present (see assignedPermissions.png)
- click the edit button
- observe the string aaaa is displayed (see visibleText.png)
- now modify the layout by replacing ReadWrite with WriteSecurity:
<dom-if if="[[_hasPermission(document, 'WriteSecurity')]]">
- synch the project
- click the edit form
- observe the string aaaa is not displayed
- after some debugging it seems the WriteSecurity is not retrieved (see debuggedPermissions.png)
Expected behavior: all the permissions should be fetched to use them when needed.