users: move sockpuppet detection from model to controller.

This commit is contained in:
evazion
2020-03-24 18:41:27 -05:00
parent 50b0b79891
commit cbd713dea8
6 changed files with 7 additions and 37 deletions

View File

@@ -78,7 +78,6 @@ class User < ApplicationRecord
validates_inclusion_of :per_page, in: (1..PostSets::Post::MAX_PER_PAGE)
validates_confirmation_of :password
validates_presence_of :comment_threshold
validate :validate_sock_puppets, :on => :create, :if => -> { Danbooru.config.enable_sock_puppet_validation? }
before_validation :normalize_blacklisted_tags
before_create :promote_to_admin_if_first_user
before_create :customize_new_user
@@ -623,14 +622,6 @@ class User < ApplicationRecord
end
end
concerning :SockPuppetMethods do
def validate_sock_puppets
if User.where(last_ip_addr: CurrentUser.ip_addr).where("created_at > ?", 1.day.ago).exists?
errors.add(:last_ip_addr, "was used recently for another account and cannot be reused for another day")
end
end
end
include BanMethods
include PasswordMethods
include AuthenticationMethods