Fix: Pundit adapter blindly ignores existing pundit_user definition#2467
Closed
theangryangel wants to merge 1 commit into
Closed
Fix: Pundit adapter blindly ignores existing pundit_user definition#2467theangryangel wants to merge 1 commit into
theangryangel wants to merge 1 commit into
Conversation
… definition. This allows additional context as per the pundit readme.
Member
|
For the scenario 1, that's my fault. I'll change all pundit calls to be suffixed with For the scenario 2, the recommended way is to set custom authorization key through action configuration. |
Author
|
Thanks for the pointer, @mshibuya. Much appreciated <3 |
jibidus
pushed a commit
to sogilis/rails_admin
that referenced
this pull request
Nov 26, 2015
jibidus
pushed a commit
to sogilis/rails_admin
that referenced
this pull request
Nov 26, 2015
This file contains hidden or 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
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.
As per the pundit readme, there are instances where I need to provide additional context about the user. I do this by defining pundit_user, however the pundit rails_admin adapter ignores this and replaces it with it's own pointing at current_user. This breaks policies that rely on the additional context.
This patch addresses this.
In addition to this I have another issue with the pundit adapter, and I'd like to include some fixes for it as well, but before just doing them I'd like to see if there's a good reason why things have been done the way they are.
Typically the method name for checking with pundit for "can I do X" will be suffixed with a "?". Currently the pundit adapter does not do this.
I see 2 problems with this:
alias_method :index, :index?) - a minor incovenienceI'd like to put a patch together that basically either prefixes the methods with rails_admin, or works more like sudosu/rails_admin_pundit where it runs through a specific method, which in turn can use a case statement.
I'd appreciate any input on that before I write a patch and start depending on it.