mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Refactor + tests
This commit is contained in:
parent
dc1ad9e6c5
commit
19e133ec6a
7 changed files with 37 additions and 25 deletions
|
@ -80,11 +80,7 @@ class EppController < ApplicationController
|
|||
end
|
||||
|
||||
# VALIDATION
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def validate_request
|
||||
handle_errors and return unless ip_white?
|
||||
|
||||
validation_method = "validate_#{params[:action]}"
|
||||
return unless respond_to?(validation_method, true)
|
||||
send(validation_method)
|
||||
|
@ -97,22 +93,6 @@ class EppController < ApplicationController
|
|||
|
||||
handle_errors and return if epp_errors.any?
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def ip_white?
|
||||
if current_user
|
||||
unless current_user.registrar.epp_ip_white?(request.ip)
|
||||
epp_errors << {
|
||||
msg: t('ip_is_not_whitelisted'),
|
||||
code: '2201'
|
||||
}
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
# let's follow grape's validations: https://github.com/intridea/grape/#parameter-validation-and-coercion
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue