mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
20 lines
462 B
Ruby
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
|