mastodon/app/models/concerns/user/registration.rb
2025-08-15 08:53:55 -04:00

20 lines
462 B
Ruby

# frozen_string_literal: true
module User::Registration
extend ActiveSupport::Concern
REGISTRATION_ATTEMPT_WAIT_TIME = 3.seconds.freeze
included do
attribute :registration_form_time, :datetime
validate :validate_registration_wait, on: :create, if: :registration_form_time?
end
private
def validate_registration_wait
errors.add(:base, I18n.t('auth.too_fast')) if registration_form_time > REGISTRATION_ATTEMPT_WAIT_TIME.ago
end
end