diff --git a/app/models/account_migration.rb b/app/models/account_migration.rb index dc22e3294..7a01e250e 100644 --- a/app/models/account_migration.rb +++ b/app/models/account_migration.rb @@ -31,10 +31,14 @@ class AccountMigration < ApplicationRecord validate :validate_migration_cooldown validate :validate_target_account - scope :within_cooldown, ->(now = Time.now.utc) { where(arel_table[:created_at].gteq(now - COOLDOWN_PERIOD)) } + scope :within_cooldown, -> { where(created_at: cooldown_duration_ago..) } attr_accessor :current_password, :current_username + def self.cooldown_duration_ago + Time.current - COOLDOWN_PERIOD + end + def save_with_challenge(current_user) if current_user.encrypted_password.present? errors.add(:current_password, :invalid) unless current_user.valid_password?(current_password)