registration_helper.rb 543 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. module RegistrationHelper
  3. extend ActiveSupport::Concern
  4. def allowed_registration?(remote_ip, invite)
  5. !Rails.configuration.x.single_user_mode && !omniauth_only? && (registrations_open? || invite&.valid_for_use?) && !ip_blocked?(remote_ip)
  6. end
  7. def registrations_open?
  8. Setting.registrations_mode != 'none'
  9. end
  10. def omniauth_only?
  11. ENV['OMNIAUTH_ONLY'] == 'true'
  12. end
  13. def ip_blocked?(remote_ip)
  14. IpBlock.where(severity: :sign_up_block).exists?(['ip >>= ?', remote_ip.to_s])
  15. end
  16. end