mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Fixed codeclimate issue
This commit is contained in:
parent
1dcfd1d414
commit
5c1cede31e
1 changed files with 7 additions and 7 deletions
|
@ -122,13 +122,9 @@ module Repp
|
|||
end
|
||||
|
||||
def check_ip_restriction
|
||||
if webclient_request?
|
||||
ip = request.headers['X-Client-IP']
|
||||
return if registrar_ip_white?(ip)
|
||||
else
|
||||
ip = request.ip
|
||||
return if @current_user.registrar.api_ip_white?(ip)
|
||||
end
|
||||
ip = webclient_request? ? request.headers['X-Client-IP'] : request.ip
|
||||
return if registrar_ip_white?(ip) && webclient_request?
|
||||
return if api_ip_white?(ip) && !webclient_request?
|
||||
|
||||
render_unauthorized_response(ip)
|
||||
end
|
||||
|
@ -139,6 +135,10 @@ module Repp
|
|||
@current_user.registrar.registrar_ip_white?(ip)
|
||||
end
|
||||
|
||||
def api_ip_white?(ip)
|
||||
@current_user.registrar.api_ip_white?(ip)
|
||||
end
|
||||
|
||||
def render_unauthorized_response(ip)
|
||||
@response = { code: 2202, message: I18n.t('registrar.authorization.ip_not_allowed', ip: ip) }
|
||||
render json: @response, status: :unauthorized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue