-
-
Notifications
You must be signed in to change notification settings - Fork 588
[5.x] Add view other authors entries
permission
#11870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.x
Are you sure you want to change the base?
Conversation
Also show entries with a blueprint that doesn’t have an author field
view other authors entries
permissionview other authors entries
permission
This is a nice PR to see, I myself created statamic/ideas#1333 to address it. I imagined there was a valid workflow where:
This would require changing
Could we perhaps have this discussion now? Or directly change the file in the PR to do this? |
@AtmoFX I think that's a valid feature request. But it might be a little overkill to add it in this PR. I'd like to keep it as simple as possible to make review easier. I see your request as a bigger overhaul of how other authors' entries are treated. But I'll leave it up to the core team to decide. |
It looks like some of the tests are failing. Are you able to take a look? |
Yes, will do. Didn't get to it yet 👍🏻 |
I fixed the tests and also added an update script to add the appropriate permissions. |
Good idea this PR, something I would like to use myself. What happens if you configure the blueprint so that you can have multiple authors on the same entry? Would this still work as intended? I would assume that all listed authors can view the entry, but not listed authors can not. |
@Jubeki This PR doesn't tackle multiple authors. It only supports entries with a single author. It might be a good idea to add support for it will make things a lot more complicated. I'm not even sure it can be done, as the queries would have to look different depending if the |
@aerni it should just be a case of doing ->where() for blueprints with max_items: 1 and ->orWhereIn() for blueprints with max_items not 1.... i.e.
|
@Jubeki I've added support for multiple authors :-) |
@duncanmcclean This is ready for review now 😃 |
This also fixes an issue where the search would include unauthorized sites if the collection had a search index.
This PR aims to solve the longstanding community request to restrict users' view access to other authors' entries.
Summary
view other authors {collection} entries
permissionauthor
field visibility depending on the user's permissionsIn Detail
Permission & Policy
This PR adds a new
view other authors {collection} entries
permission and makes the existing author-related permissions its children. The updated policy is pretty straightforward. The tricky part was getting the query and filtering for the entries index listing and fieldtype working correctly. Thanks to @ryanmitchell for lending a hand.Users don't require any of the
... other authors {collection} entries
permissions to:Author Field Visibility
This PR also dynamically changes the
author
field visibility and listing column depending on the user's permissions:author
field ishidden
and the column removed from the index listing if the user has noview
permission.author
field isread_only
if the user hasview
permissionauthor
field isvisible
if the user hasedit
permissionThe field visibility is changed in an
EntryBlueprintFound
listener so that users can override it if needed.Update Script
The new
view other authors {collection} entries
is added to roles that have an existingedit other authors {collection} entries
permission. You will have to update$this->isUpdatingTo('5.59');
to the correct version once you're ready to release this.