prefer each over for

This commit is contained in:
Georg Kahest 2017-11-14 12:51:44 +02:00
parent e62bb19a7e
commit abeeec3baf
2 changed files with 7 additions and 8 deletions

View file

@ -156,15 +156,15 @@ class Registrar
def find_user_by_idc_and_allowed(idc)
return User.new unless idc
possible_users = ApiUser.where(identity_code: idc) || User.new
for selected_user in 0..possible_users.count
if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(request.ip)
break
possible_users eacho do |selected_user|
if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip)
return selected_user
end
end
possible_users[selected_user]
end
def check_ip_restriction
ip_restriction = Authorization::RestrictedIP.new(request.ip)
allowed = ip_restriction.can_access_registrar_area_sign_in_page?

View file

@ -58,12 +58,11 @@ class ApiUser < User
return false if ip.blank?
possible_users = where(identity_code: identity_code)
for selected_user in 0..possible_users.count
if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(ip)
break
possible_users eacho do |selected_user|
if selected_user.registrar.white_ips.registrar_area.include_ip?(ip)
return selected_user
end
end
possible_users[selected_user]
end
end