summaryrefslogtreecommitdiff
path: root/lib/gitlab/user_access.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/user_access.rb')
-rw-r--r--lib/gitlab/user_access.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 3b922da7ced..9c066627011 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -1,5 +1,11 @@
module Gitlab
class UserAccess
+ extend Gitlab::Cache::RequestStoreWrap
+
+ request_store_wrap_key do
+ [user&.id, project&.id]
+ end
+
attr_reader :user, :project
def initialize(user, project: nil)
@@ -28,7 +34,7 @@ module Gitlab
true
end
- def can_create_tag?(ref)
+ request_store_wrap def can_create_tag?(ref)
return false unless can_access_git?
if ProtectedTag.protected?(project, ref)
@@ -38,7 +44,7 @@ module Gitlab
end
end
- def can_delete_branch?(ref)
+ request_store_wrap def can_delete_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)
@@ -48,7 +54,7 @@ module Gitlab
end
end
- def can_push_to_branch?(ref)
+ request_store_wrap def can_push_to_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)
@@ -60,7 +66,7 @@ module Gitlab
end
end
- def can_merge_to_branch?(ref)
+ request_store_wrap def can_merge_to_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)