base_service.rb 546 Bytes
Newer Older
1
2
3
4
5
6
7
module Groups
  class BaseService
    attr_accessor :group, :current_user, :params

    def initialize(group, user, params = {})
      @group, @current_user, @params = group, user, params.dup
    end
8

Felipe Artur's avatar
Felipe Artur committed
9
10
    private

11
12
    def visibility_allowed_for_user?
      level = group.visibility_level
Felipe Artur's avatar
Felipe Artur committed
13
14
      allowed_by_user  = Gitlab::VisibilityLevel.allowed_for?(current_user, level)

15
16
17
      group.errors.add(:visibility_level, "#{level} has been restricted by your GitLab administrator.") unless allowed_by_user
      
      allowed_by_user
18
    end
19
20
  end
end