BigW Consortium Gitlab

user_policy.rb 437 Bytes
Newer Older
http://jneen.net/ committed
1 2 3 4 5
class UserPolicy < BasePolicy
  include Gitlab::CurrentSettings

  def rules
    can! :read_user if @user || !restricted_public_level?
6 7 8 9 10 11 12 13

    if @user
      if @user.admin? || @subject == @user
        can! :destroy_user
      end

      cannot! :destroy_user if @subject.ghost?
    end
http://jneen.net/ committed
14 15 16 17 18 19
  end

  def restricted_public_level?
    current_application_settings.restricted_visibility_levels.include?(Gitlab::VisibilityLevel::PUBLIC)
  end
end