mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
Log REPP requests
This commit is contained in:
parent
0544dbd3ff
commit
568c52129f
8 changed files with 38 additions and 16 deletions
|
@ -4,11 +4,24 @@ module Repp
|
|||
prefix :repp
|
||||
|
||||
http_basic do |username, password|
|
||||
@current_user ||= EppUser.find_by(username: username, password: password)
|
||||
@current_api_user ||= EppUser.find_by(username: username, password: password)
|
||||
end
|
||||
|
||||
helpers do
|
||||
attr_reader :current_user
|
||||
attr_reader :current_api_user
|
||||
end
|
||||
|
||||
after do
|
||||
ApiLog::ReppLog.create({
|
||||
request_path: request.path,
|
||||
request_method: request.request_method,
|
||||
request_params: request.params.except('route_info').to_json,
|
||||
response: @response.to_json,
|
||||
response_code: status,
|
||||
api_user_name: current_api_user.try(:username),
|
||||
api_user_registrar: current_api_user.try(:registrar).try(:to_s),
|
||||
ip: request.ip
|
||||
})
|
||||
end
|
||||
|
||||
mount Repp::DomainV1
|
||||
|
|
|
@ -5,8 +5,8 @@ module Repp
|
|||
resource :contacts do
|
||||
desc 'Return list of contact'
|
||||
get '/' do
|
||||
contacts = current_user.registrar.contacts.page(params[:page])
|
||||
{
|
||||
contacts = current_api_user.registrar.contacts.page(params[:page])
|
||||
@response = {
|
||||
contacts: contacts,
|
||||
total_pages: contacts.total_pages
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ module Repp
|
|||
resource :domains do
|
||||
desc 'Return list of domains'
|
||||
get '/' do
|
||||
domains = current_user.registrar.domains.page(params[:page])
|
||||
{
|
||||
domains = current_api_user.registrar.domains.page(params[:page])
|
||||
@response = {
|
||||
domains: domains,
|
||||
total_pages: domains.total_pages
|
||||
}
|
||||
|
|
|
@ -121,14 +121,15 @@ module Epp::Common
|
|||
|
||||
def write_to_epp_log
|
||||
request_object = OBJECT_TYPES[params_hash['epp']['xmlns:ns2']] if params[:frame]
|
||||
ApiLog::EppLog.create!({
|
||||
ApiLog::EppLog.create({
|
||||
request: params[:frame],
|
||||
request_command: params[:command],
|
||||
request_successful: epp_errors.empty?,
|
||||
request_object: request_object,
|
||||
response: @response,
|
||||
api_user_name: @epp_user.try(:to_s) || current_epp_user.try(:to_s),
|
||||
api_user_registrar: @epp_user.try(:registrar).try(:to_s) || current_epp_user.try(:registrar).try(:to_s)
|
||||
api_user_registrar: @epp_user.try(:registrar).try(:to_s) || current_epp_user.try(:registrar).try(:to_s),
|
||||
ip: request.ip
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
%dt= t('registrar')
|
||||
%dd= @epp_log.api_user_registrar
|
||||
|
||||
%dt= t('ip')
|
||||
%dd= @epp_log.ip
|
||||
|
||||
%dt= t('created_at')
|
||||
%dd= @epp_log.created_at
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue