-
Notifications
You must be signed in to change notification settings - Fork 36
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
Implement authorizable #1
Comments
This is a great idea, I will either document or build the necessary features within a week. |
I am actually unsure how this should work. Nova's BelongsToMany models that relationship as it's own CRUD view. That means that authorization can happen over every single relation, and they can be shown independently of each other (it uses attach and detach to make/remove the relations). In the case of For example, let's say I don't know how we would go about separating all the values that are able to be removed but not visible from the list of things that is passed in. |
If it is not visible (the user has no right to select it) it should be removed / not visible. This package: Loops over the results and filters them based on the attach* policy method if im correctly. Is that an option? Or would that be way too heavy? |
It may not be visible to the current user, but it may be visible to another user who may have set that particular relationship previously (it was visible to that user). Re: "it should be removed": that is effectively allowing the current user to "detach" the relationship (implicitly, since it's not available to them through the policy), which I think is also the wrong thing to do. Let me see if I can come up with another real life scenario to test this against. I feel like there is a problem we have to solve with regards to maintaining the state of relationships that a user may not have access to see (or change)... |
I think the solution to this problem would be something like this: If the model has an association already set up and the current user doesn't have permission to remove that association, it should be displayed in a read only fashion, then when syncing, be sure to add that read only association to the sync array before syncing. It feels kind of hacky, but it solves the root issue. |
Hello,
Is it possible to implement the Laravel\Nova\Authorizable trait so the attachModelName policy methods are respected? Or implement the authorize function from the BelongsToManyField?
Now I'm able to see all the possible relationship values even if I have no acces to see them.
Thanks in advance!
The text was updated successfully, but these errors were encountered: