diff options
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r-- | app/models/ability.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index eb645bcd653..4da4d113a7f 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -77,6 +77,8 @@ class Ability policy = policy_for(user, subject) + before_check(policy, ability.to_sym, user, subject, opts) + case opts[:scope] when :user DeclarativePolicy.user_scope { policy.allowed?(ability) } @@ -92,6 +94,11 @@ class Ability forget_runner_result(policy.runner(ability)) if policy && ability_forgetting? end + # Hook call right before ability check. + def before_check(policy, ability, user, subject, opts) + # See Support::AbilityCheck and Support::PermissionsCheck. + end + def policy_for(user, subject = :global) DeclarativePolicy.policy_for(user, subject, cache: ::Gitlab::SafeRequestStore.storage) end |