-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Fix user create
& changeRole
permissions/options handling in Panel UI
#6612
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distantnative
force-pushed
the
fix/5146-user-changeRole-permission
branch
from
August 11, 2024 21:16
0358f68
to
188c76e
Compare
distantnative
force-pushed
the
fix/5146-user-changeRole-permission
branch
from
August 31, 2024 10:32
188c76e
to
abce099
Compare
distantnative
force-pushed
the
fix/5146-user-changeRole-permission
branch
from
August 31, 2024 11:09
abce099
to
1e5a2f9
Compare
distantnative
force-pushed
the
fix/5146-user-changeRole-permission
branch
from
September 7, 2024 13:48
1e5a2f9
to
87213bc
Compare
distantnative
added
the
needs: two-person review 🧑🤝🧑
PR must only be merged with two approvals
label
Sep 7, 2024
Support user options again
distantnative
changed the title
Fix
Fix user Sep 7, 2024
changeRole
permission handlingcreate
& changeRole
permissions/options handling in Panel UI
distantnative
removed
the
needs: two-person review 🧑🤝🧑
PR must only be merged with two approvals
label
Sep 7, 2024
Closing this as we now have all parts from this PR as smaller PRs ready. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
$user->roles($purpose)
#6653Panel\Field::role()
allow passing$roles
#6654Roles
filter methods check #6655UserRules
#6657UserPermissions
#6658UserRules::create()
validate roles #6694Summary of changes
Cms\User::roles()
:User::roles($context)
andApp::roles($context)
which apply->canBeChanged()
or->canBeCreated()
accordingly to the context.user.create
anduser.changeRole
$roles
toPanel\Field::role()
using the right$context
to retrieve the roles depending on their actionUserPermssions::canChangeRole()
can be true even if only one role is available - as this isn't a permissions restriction. Instead this check is performed separately where the UI needs it.Reasoning
The main issue of #5146 why the permission wasn't reflected in the UI, was
UserPermissions::canChangeRole
only checking ifUser::roles()
returns more than one role. However,User::roles()
would always only return the current role for non-admins. That's why the permission itself never was acknowledged. Fixing these now really relies on the permission.Moreover, in the refactoring to Panel backend dialogs etc. it got lost to filter available roles further by applying
->canBeChanged()
or->canBeCreated()
.Additional context
As
UserRules::changeRole()
was fully restrictive in place, this is no security fix - the permission was always fully enforced. Even more, the Panel UI was falsely more restrictive than it should've been based on the permissions.Changelog
Fixes
create
andchangeRole
permission and user optionsuser permissions: changeRole has no effect #5146
Enhancements
Docs
user.changeRole
ANDusers.changeRole
Ready?
For review team