diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index be7b5e3a6..bc9152b78 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -70,12 +70,8 @@ def after_sign_up_path_for(_resource) private def check_registration_limit - timeframe = (ENV["MAMPF_REGISTRATION_TIMEFRAME"] || 15).to_i.minutes - threshold_date = DateTime.now - timeframe - num_new_registrations = User.where( - "users.confirmed_at is NULL and users.created_at > '#{threshold_date}'" - ).count - + timeframe = ((ENV["MAMPF_REGISTRATION_TIMEFRAME"] || 15).to_i.minutes.ago..) + num_new_registrations = User.where(confirmed_at: nil, created_at: timeframe).count max_registrations = (ENV["MAMPF_MAX_REGISTRATION_PER_TIMEFRAME"] || 40).to_i return if num_new_registrations <= max_registrations