mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Save REPP log after every request
This commit is contained in:
parent
9b8d74fe30
commit
6d96a09b5c
2 changed files with 12 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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 } }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue