Merge branch 'story/118912395-epp-log' into staging

# Conflicts:
#	app/models/domain.rb
This commit is contained in:
Vladimir Krylov 2016-05-20 16:39:14 +03:00
commit 229a249c36
7 changed files with 52 additions and 10 deletions

View file

@ -56,4 +56,8 @@ class Epp::KeyrelaysController < EppController
# domain
end
def resource
@domain
end
end

View file

@ -54,4 +54,8 @@ class Epp::PollsController < EppController
def validate_poll
requires_attribute 'poll', 'op', values: %(ack req), allow_blank: true
end
def resource
@message
end
end

View file

@ -137,4 +137,9 @@ class Epp::SessionsController < EppController
pw = params[:parsed_frame].css('pw').first.text
{ username: user, password: pw }
end
private
def resource
@api_user
end
end

View file

@ -6,8 +6,15 @@ class EppController < ApplicationController
before_action :generate_svtrid
before_action :latin_only
before_action :validate_against_schema
before_action :validate_request
before_action :update_epp_session
around_action :catch_epp_errors
helper_method :current_user
helper_method :resource
def validate_against_schema
return if ['hello', 'error', 'keyrelay'].include?(params[:action])
schema.validate(params[:nokogiri_frame]).each do |error|
@ -20,10 +27,7 @@ class EppController < ApplicationController
handle_errors and return if epp_errors.any?
end
before_action :validate_request
before_action :update_epp_session
around_action :catch_epp_errors
def catch_epp_errors
err = catch(:epp_error) do
yield
@ -34,7 +38,6 @@ class EppController < ApplicationController
handle_errors
end
helper_method :current_user
rescue_from StandardError do |e|
@errors ||= []
@ -367,7 +370,7 @@ class EppController < ApplicationController
request: trimmed_request,
request_command: request_command,
request_successful: epp_errors.empty?,
request_object: params[:epp_object_type],
request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type],
response: @response,
api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public',
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s),
@ -383,4 +386,9 @@ class EppController < ApplicationController
return if current_user.blank?
counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
end
def resource
name = self.class.to_s.sub("Epp::","").sub("Controller","").underscore.singularize
instance_variable_get("@#{name}")
end
end