Skip to content
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

[Docs example] Check for 'all' or 'any' permissions before specific permissions #2694

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

ceilidhboy
Copy link
Contributor

Shouldn't the check for edit all posts or delete any post be done first, before checking if a user can edit or delete their own posts?

The original code checked if the user can edit their own posts and, if so, would return false if they were not the post author, even though they have the permission to edit any post.

By performing the all/any check first, these permissions still work correctly when the user also has permissions to edit or delete their own posts.

Shouldn't the check for `edit all posts` or `delete any post` be done first, before checking if a user can edit or delete their own posts?

The original code checked if the user can edit their own posts and, if so, would return false if they were not the post auther, **even though they had the permission to edit any post**.

By performing the `all`/`any` check first, these permissions still work correctly when the user also has permissions to edit or delete their own posts.
@drbyte
Copy link
Collaborator

drbyte commented Jul 26, 2024

Yes. Thanks.
Granted, someone might prefer the other way, but of course they can write their policy however they choose!

@drbyte drbyte merged commit f81fb02 into spatie:main Jul 26, 2024
26 checks passed
@drbyte drbyte changed the title Check for 'all' or 'any' permissions before specific permissions [Docs] Check for 'all' or 'any' permissions before specific permissions Jul 26, 2024
@drbyte drbyte changed the title [Docs] Check for 'all' or 'any' permissions before specific permissions [Docs example] Check for 'all' or 'any' permissions before specific permissions Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants