Directus: Hide items to other users

Viewed 1384

Scenario:

  • I have 3 users with different roles (admin, siteAadmin, and siteBadmin).
  • I have a collection which is consumed by 2 sites (siteA, siteB).
  • a custom hook is setup for the collection to send external email to admin user
  • Posting data via public API.

Goal: I want to hide the data coming from siteA on siteBadmin listing. Is that possible without creating a custom page? Or is it best to create a duplicate collection for siteB instead?

Any other alternative to achieve the goal?

TIA

1 Answers

You can currently use the "role" permissions to restrict a collection's items to a certain role. This is based on an "owner" field... so you would need to ensure the collection has that field and permissions are setup accordingly:

https://docs.directus.io/guides/permissions.html#read

In the near future (2-3 months) we'll be releasing a new version of Directus with dynamic permissions that will let you do this in more flexible ways:

https://github.com/directus/api/issues/511

Related