Merge pull request #4039 from evazion/fix-4038

Fix #4038: Attempting to create an IP-ban bans the creator.
This commit is contained in:
Albert Yi
2019-01-09 14:47:32 -08:00
committed by GitHub
7 changed files with 26 additions and 14 deletions

View File

@@ -178,7 +178,7 @@ class ApplicationRecord < ActiveRecord::Base
protected
def hidden_attributes
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr]
end
def method_attributes
@@ -243,7 +243,6 @@ class ApplicationRecord < ActiveRecord::Base
if rec.creator_id.nil?
rec.creator_id = CurrentUser.id
rec.creator_ip_addr = CurrentUser.ip_addr if rec.respond_to?(:creator_ip_addr=)
rec.ip_addr = CurrentUser.ip_addr if rec.respond_to?(:ip_addr=)
end
end

View File

@@ -26,7 +26,7 @@ class IpBan < ApplicationRecord
end
def self.query(user_ids)
comments = count_by_ip_addr("comments", user_ids, "creator_id", "ip_addr")
comments = count_by_ip_addr("comments", user_ids, "creator_id", "creator_ip_addr")
notes = count_by_ip_addr("note_versions", user_ids, "updater_id", "updater_ip_addr")
# pools = count_by_ip_addr("pool_versions", user_ids, "updater_id", "updater_ip_addr")
wiki_pages = count_by_ip_addr("wiki_page_versions", user_ids, "updater_id", "updater_ip_addr")