Custom Conditions for User Permissions

Hi, we are using the Enterprise Edition and want to set up custom conditions for user permissions.
So far I have found the below article which states how to set it up.

We have a collection ‘A’ to which we want to restrict read and write access based on the current login user id.
We set up a one-to-many relation field(called AffiliatedUser) to admin users and the below condition in bootstrap.js file. However we keep on getting error.
It will be really helpful if someone can tell me what are we doing wrong.

strapi.admin.services.permission.conditionProvider.register({
displayName: ‘CompanyUser_TEST’,
name: ‘companyuser_test’,
plugin: ‘admin’,
handler: { AffiliatedUser: { $contains: user.id } },
})

We are using ver3.5.1.
Thanks in advance

I was able to find this Q&A(Editor role cannot edit Single Types) and figure out the mistake we were making while referring user but I have another issue now.
I changed the condition to below and only the records that the user is affiliated to are being displayed in list view of the collection.
However, I can only see value of ID and publication status of the record in list view and not any other fields. Also, when I click on the record it says the user doesn’t have permission to access the record.
Is there anything still wrong in the condition statement?

strapi.admin.services.permission.conditionProvider.register({
displayName: ‘CompanyUser_TEST’,
name: ‘companyuser_test’,
plugin: ‘admin’,
handler: (user) => { return { ‘AffiliatedUser’: user.id }; },
})

Hi. İ have same issue. Are you find any solution?

1 Like