* Add: #348 新規登録の上限人数 * Fix test * Fix test * Wip * Fix test * Add invite support * Wip * Fix test * Fix test * Fix test
23 lines
616 B
Ruby
23 lines
616 B
Ruby
# frozen_string_literal: true
|
|
|
|
module RegistrationHelper
|
|
extend ActiveSupport::Concern
|
|
|
|
include RegistrationLimitationHelper
|
|
|
|
def allowed_registration?(remote_ip, invite)
|
|
!Rails.configuration.x.single_user_mode && !omniauth_only? && ((registrations_open? && !reach_registrations_limit?) || 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)
|
|
IpBlock.where(severity: :sign_up_block).exists?(['ip >>= ?', remote_ip.to_s])
|
|
end
|
|
end
|