Pundit, the authorization gem, doesn't support passing "context" when raising an error. Action Policy does. I want to pass context to display a custom error message and redirect based on what kind of authorization failed.
Abstract adding error message and redirect path to ApplicationPolicy
Implement ColdMessagePolicy to handle the different failure paths (see the before_actions in ColdMessageController)
I'm open to lots of discussion on this one as I'n not 100% sure Action Policy is the right move. So feel free to submit a draft PR to kick off a conversation!
The text was updated successfully, but these errors were encountered:
joemasilotti
changed the title
Spike on Action Policy to pass message and redirect URL on authorization failure
Migrate Pundit to Action Policy to pass message and redirect URL on authorization failure
May 9, 2022
We're thinking about migrating to action policy at work from petergate (https://github.com/elorest/petergate) Petergate is being used in two repos, but we have i18n issues to support and there's the whole passing context thing to consider also. I have to admit being curious about this but I also know I can't commit to look at it until after RailsConf.
Pundit, the authorization gem, doesn't support passing "context" when raising an error. Action Policy does. I want to pass context to display a custom error message and redirect based on what kind of authorization failed.
A PR addressing this issue should:
ApplicationPolicyColdMessagePolicyto handle the different failure paths (see thebefore_actions inColdMessageController)I'm open to lots of discussion on this one as I'n not 100% sure Action Policy is the right move. So feel free to submit a draft PR to kick off a conversation!
The text was updated successfully, but these errors were encountered: