summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-18 08:52:04 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-18 08:52:04 +0000
commit7e2d89989a48ecd55d3f118d7bf8c3a00e1038cb (patch)
tree11f24f04e0f11b451c84a224e0d1f07cfed25928 /app
parenta12a8608e6160bef7f2edca1e20192b69a83ff54 (diff)
downloadgitlab-ce-7e2d89989a48ecd55d3f118d7bf8c3a00e1038cb.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/policies/group_policy.rb7
-rw-r--r--app/policies/project_policy.rb7
2 files changed, 14 insertions, 0 deletions
diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb
index 62f66093875..92cba5f8f7d 100644
--- a/app/policies/group_policy.rb
+++ b/app/policies/group_policy.rb
@@ -166,6 +166,7 @@ class GroupPolicy < BasePolicy
def access_level
return GroupMember::NO_ACCESS if @user.nil?
+ return GroupMember::NO_ACCESS unless user_is_user?
@access_level ||= lookup_access_level!
end
@@ -173,6 +174,12 @@ class GroupPolicy < BasePolicy
def lookup_access_level!
@subject.max_member_access_for_user(@user)
end
+
+ private
+
+ def user_is_user?
+ user.is_a?(User)
+ end
end
GroupPolicy.prepend_if_ee('EE::GroupPolicy')
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb
index 39b39bd2fce..3a245119cb7 100644
--- a/app/policies/project_policy.rb
+++ b/app/policies/project_policy.rb
@@ -603,8 +603,13 @@ class ProjectPolicy < BasePolicy
private
+ def user_is_user?
+ user.is_a?(User)
+ end
+
def team_member?
return false if @user.nil?
+ return false unless user_is_user?
greedy_load_subject = false
@@ -632,6 +637,7 @@ class ProjectPolicy < BasePolicy
# rubocop: disable CodeReuse/ActiveRecord
def project_group_member?
return false if @user.nil?
+ return false unless user_is_user?
project.group &&
(
@@ -643,6 +649,7 @@ class ProjectPolicy < BasePolicy
def team_access_level
return -1 if @user.nil?
+ return -1 unless user_is_user?
lookup_access_level!
end