2023-11-13 13:27:00 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RegistrationHelper
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def allowed_registration?(remote_ip, invite)
|
|
|
|
!Rails.configuration.x.single_user_mode && !omniauth_only? && (registrations_open? || invite&.valid_for_use?) && !ip_blocked?(remote_ip)
|
|
|
|
end
|
|
|
|
|
|
|
|
def registrations_open?
|
|
|
|
Setting.registrations_mode != 'none'
|
|
|
|
end
|
|
|
|
|
|
|
|
def omniauth_only?
|
|
|
|
ENV['OMNIAUTH_ONLY'] == 'true'
|
|
|
|
end
|
|
|
|
|
|
|
|
def ip_blocked?(remote_ip)
|
2024-11-08 10:08:36 +00:00
|
|
|
IpBlock.where(severity: :sign_up_block).containing(remote_ip.to_s).exists?
|
2023-11-13 13:27:00 +00:00
|
|
|
end
|
|
|
|
end
|