FIX: when adding an IP to the spammer list, check the broader ban list

first

FEATURE: allow admins to search users using IP ranges
This commit is contained in:
Régis Hanol
2014-11-21 18:16:06 +01:00
parent 0847cb5ea7
commit 0398ab7514
5 changed files with 32 additions and 18 deletions

View File

@ -42,8 +42,8 @@ class AdminUserIndexQuery
def filter_by_search
if params[:filter].present?
if params[:filter] =~ Resolv::IPv4::Regex || params[:filter] =~ Resolv::IPv6::Regex
@query.where('ip_address = :ip OR registration_ip_address = :ip', ip: params[:filter])
if ip = IPAddr.new(params[:filter]) rescue nil
@query.where('ip_address <<= :ip OR registration_ip_address <<= :ip', ip: ip.to_cidr_s)
else
@query.where('username_lower ILIKE :filter OR email ILIKE :filter', filter: "%#{params[:filter]}%")
end