Fixed codeclimate issue

This commit is contained in:
Sergei Tsoganov 2023-07-10 15:56:45 +03:00
parent 1dcfd1d414
commit 5c1cede31e

View file

@ -122,13 +122,9 @@ module Repp
end end
def check_ip_restriction def check_ip_restriction
if webclient_request? ip = webclient_request? ? request.headers['X-Client-IP'] : request.ip
ip = request.headers['X-Client-IP'] return if registrar_ip_white?(ip) && webclient_request?
return if registrar_ip_white?(ip) return if api_ip_white?(ip) && !webclient_request?
else
ip = request.ip
return if @current_user.registrar.api_ip_white?(ip)
end
render_unauthorized_response(ip) render_unauthorized_response(ip)
end end
@ -139,6 +135,10 @@ module Repp
@current_user.registrar.registrar_ip_white?(ip) @current_user.registrar.registrar_ip_white?(ip)
end end
def api_ip_white?(ip)
@current_user.registrar.api_ip_white?(ip)
end
def render_unauthorized_response(ip) def render_unauthorized_response(ip)
@response = { code: 2202, message: I18n.t('registrar.authorization.ip_not_allowed', ip: ip) } @response = { code: 2202, message: I18n.t('registrar.authorization.ip_not_allowed', ip: ip) }
render json: @response, status: :unauthorized render json: @response, status: :unauthorized