-
Notifications
You must be signed in to change notification settings - Fork 51
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
passing optional params to authorize_resource #44
Comments
If Canada will not support an options argument, then I think the only way from Canary's perspective would be to take options from the plug Then the user could rely on these options within the One option is for Canary to stop relying on Canada, but copy the implementation, allowing for an options argument. I'm open to suggestions. |
I thought about few ideas like this but as you said it would be hack. I am all for having our own permission definitions module. I understand that this change breaks the backward compatibility, so I suggest that make it a configuration to what module use. Of course we can also convince @jarednorman that this is something that is needed and implement it in |
If you want to whip up a proof of concept for Canada, I'll take a look, but no guarantees. I'm currently quite happy with its simplicity and don't want to add anything unless I'm sure it's worth it. |
+1 to this. My use case is that my defimpl Canada.Can, for: SampleProject.Account.User do
def can?(current_user, :index_by_user, Applicant) do
# user_id should come from the query parameters but right now there's no way to do this
is_team_lead_of_user(current_user.id, user_id)
end
end |
I think authorize_controller should fix your problem. It is committed but the new version of canary is not out. So what it does is that instead of model it tells can? function which user is requesting which controller with what action. |
@ghatighorias it's still an improvement but doesn't solve my case :( I want to give access to members of a group to Page A but not Page B. So the variables of making this decision are:
I wish you had implemented it to call
|
@ghatighorias just noticed that it was already there! |
@slashmili I don't see it is to be of a huge improvement. PS: authorize_controller uses ":canary_controller" . you can populate that with a tupe {group, controller} and then have it in the can? function |
Not really they user is loaded from Session. So any user might visit a route with
That's a good idea! I'll give it a try. |
I explained why I need it here: jarednorman/canada#11
Do you have any suggestion or alternative way of doing that?
The text was updated successfully, but these errors were encountered: