summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-02-07 04:10:13 +0000
committerDouwe Maan <douwe@gitlab.com>2017-02-07 04:10:13 +0000
commit50f5960c72b4ff8b553bb0f7e8f649ac413f6ce0 (patch)
tree3fce35b12e29a10b538ce030ad7d661d332ba3e0 /lib
parent437b46b9a18b1eb26c0caecf0ff6863d8ad9faa7 (diff)
parentf5a798c7434bf236f36b399347c49fa3edf1f04e (diff)
downloadgitlab-ce-50f5960c72b4ff8b553bb0f7e8f649ac413f6ce0.tar.gz
Merge branch 'ee-1439-read-only-user' into 'master'
Backport changes from gitlab-org/gitlab-ee!998 See merge request !8984
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/visibility_level.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index c7953af29dd..a4e966e4016 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -13,7 +13,19 @@ module Gitlab
scope :public_and_internal_only, -> { where(visibility_level: [PUBLIC, INTERNAL] ) }
scope :non_public_only, -> { where.not(visibility_level: PUBLIC) }
- scope :public_to_user, -> (user) { user && !user.external ? public_and_internal_only : public_only }
+ scope :public_to_user, -> (user) do
+ if user
+ if user.admin?
+ all
+ elsif !user.external?
+ public_and_internal_only
+ else
+ public_only
+ end
+ else
+ public_only
+ end
+ end
end
PRIVATE = 0 unless const_defined?(:PRIVATE)