mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Merge pull request #262 from elabs/strict-verify-scope
Don't verify policy scope if called from view
This commit is contained in:
commit
3bd1d74c7f
1 changed files with 15 additions and 2 deletions
|
@ -56,10 +56,17 @@ module Pundit
|
|||
end
|
||||
end
|
||||
|
||||
module Helper
|
||||
def policy_scope(scope)
|
||||
pundit_policy_scope(scope)
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
helper Helper if respond_to?(:helper)
|
||||
if respond_to?(:helper_method)
|
||||
helper_method :policy_scope
|
||||
helper_method :policy
|
||||
helper_method :pundit_policy_scope
|
||||
helper_method :pundit_user
|
||||
end
|
||||
if respond_to?(:hide_action)
|
||||
|
@ -101,7 +108,7 @@ module Pundit
|
|||
|
||||
def policy_scope(scope)
|
||||
@_pundit_policy_scoped = true
|
||||
policy_scopes[scope] ||= Pundit.policy_scope!(pundit_user, scope)
|
||||
pundit_policy_scope(scope)
|
||||
end
|
||||
|
||||
def policy(record)
|
||||
|
@ -119,4 +126,10 @@ module Pundit
|
|||
def pundit_user
|
||||
current_user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pundit_policy_scope(scope)
|
||||
policy_scopes[scope] ||= Pundit.policy_scope!(pundit_user, scope)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue