gitlab-org--gitlab-foss/app/services/concerns/update_visibility_level.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
638 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-09-02 02:59:24 -04:00
module UpdateVisibilityLevel
# check that user is allowed to set specified visibility_level
2017-09-05 20:10:30 -04:00
def valid_visibility_level_change?(target, new_visibility)
return true unless new_visibility
new_visibility_level = Gitlab::VisibilityLevel.level_value(new_visibility)
if new_visibility_level != target.visibility_level_value
2017-09-02 02:59:24 -04:00
unless can?(current_user, :change_visibility_level, target) &&
Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility_level)
2017-09-02 02:59:24 -04:00
deny_visibility_level(target, new_visibility_level)
2017-09-02 02:59:24 -04:00
return false
end
end
true
end
end