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 Mods being able to edit Admins, Split permissions #2113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I cannot add comments to the Serializer.
$canEdit = $gate->allows('edit.credentials') || $gate->allows('edit.groups') || $gate->allows('edit.username') ? true : false;
The last ?:
is superfluous. I also highly doubt it does what you expect. The condition applies only to the last gate allow method, not all three.
Why exactly are there no new policy methods, are these magically applied? Would you have kept the user
as an argument to the allows
method and created the methods on the UserPolicy
you could have moved the EditUserHandler
change to the Policy to enforce it globally, I think that's the better solution here..
Thanks for the feedback @luceos I'll work on implementing your suggestions, I think the problem stems from my lack of experience working with Flarums permission systems and not know exactly how policies got applied. With your insight I think I can do this way better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this could work without a policy: if no policy governs a permission, there'll be a check as to whether the user belongs to a group that has that permission.
However, I agree that a policy could be useful here, as that'd be a better place to put the if user->isAdmin() => assertAdmin($actor)
logic, so that we keep the permission layer separate from the editing logic.
I agree with the existing comments. Please ping me again and I'll do an actual review when more code is pushed. |
7c943eb
to
674417c
Compare
@clarkwinkelmann I've refactored it almost completely |
Because we now auto-format our JS code with Prettier, this branch now has conflicts with Please take the steps outlined in the forum to resolve the conflicts. |
This commit makes it so only admins can edit other admin emails and passwords.
[ci skip] [skip ci]
e01422e
to
a543389
Compare
Rebase was completed |
I'd like to discuss the naming convention for the |
@franzliedke when you get back from vacation, what's the verdict on permission naming? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Clark brings up a good point here: #2113 (comment), a warning message would be nice. Other than that, the only thing left is Franz's decision on the ability naming.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change it to camel case, and then switch back to dot separated later if we decide that to be the new convention. This also needs to be updated for mithril 2.
One major concern as I thought back to this: we currently have extensions using $actor->can('edit', $user)
, including our own nicknames. If we remove edit
without a BC layer, we could run into issues. I think we should re-think this split, keeping user.edit
as the main user edit permission, and requiring individual permissions (like user.editGroups
) for higher level things.
Closing in favor of #2620 |
**Fixes #1965 **
Changes proposed in this pull request:
Reviewers should focus on:
Screenshot
Confirmed
composer test
).Required changes: