while logging in with id/mid pick only users who have whitelisted ip

This commit is contained in:
Georg Kahest 2017-11-13 17:14:26 +02:00
parent 1c6d47380f
commit 06049cd22f
2 changed files with 30 additions and 3 deletions

View file

@ -51,6 +51,21 @@ class ApiUser < User
find_by(identity_code: identity_code)
end
def find_by_idc_data_and_allowed(idc_data,ip)
return false if idc_data.blank?
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
return false if ip.blank?
possible_users = where(identity_code: identity_code)
for i in 0..possible_users.count
if possible_users[i].registrar.white_ips.registrar_area.include_ip?(ip)
break
end
end
possible_users[i]
end
end
def registrar_typeahead