diff --git a/app/controllers/repp/v1/base_controller.rb b/app/controllers/repp/v1/base_controller.rb index 882c26fb0..7aac47d80 100644 --- a/app/controllers/repp/v1/base_controller.rb +++ b/app/controllers/repp/v1/base_controller.rb @@ -4,13 +4,22 @@ module Repp rescue_from ActiveRecord::RecordNotFound, with: :not_found_error before_action :authenticate_user before_action :check_ip_restriction - attr_reader :current_user rescue_from ActionController::ParameterMissing do |exception| render json: { code: 2003, message: exception }, status: :bad_request end + after_action do + ApiLog::ReppLog.create( + { request_path: request.path, request_method: request.request_method, + request_params: request.params.except('route_info').to_json, uuid: request.try(:uuid), + response: @response.to_json, response_code: status, ip: request.ip, + api_user_name: current_user.try(:username), + api_user_registrar: current_user.try(:registrar).try(:to_s) } + ) + end + private def render_success(code: nil, message: nil, data: nil) diff --git a/app/controllers/repp/v1/domains_controller.rb b/app/controllers/repp/v1/domains_controller.rb index 32ae61687..e130d7a68 100644 --- a/app/controllers/repp/v1/domains_controller.rb +++ b/app/controllers/repp/v1/domains_controller.rb @@ -33,7 +33,7 @@ module Repp initiate_transfer(transfer) end - if @errors.any + if @errors.any? render_success(data: { errors: @errors }) else render_success(data: successful) @@ -42,7 +42,7 @@ module Repp def initiate_transfer(transfer) domain = transferable_domain(transfer[:domain_name], transfer[:transfer_code]) - next unless domain + return unless domain DomainTransfer.request(domain, current_user.registrar) @successful << { type: 'domain_transfer', attributes: { domain_name: domain.name } }