mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
Api log contains only username + refactor #2793
This commit is contained in:
parent
682d2918ce
commit
7f44227370
8 changed files with 33 additions and 42 deletions
|
@ -56,15 +56,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def user_for_paper_trail
|
||||
if defined?(current_user) && current_user.present?
|
||||
# Most of the time it's not loaded in correct time because PaperTrail before filter kicks in
|
||||
# before current_user is defined. PaperTrail is triggered also at current_user
|
||||
api_user_log_str(current_user)
|
||||
elsif current_user.present?
|
||||
"#{current_user.id}-#{current_user.username}"
|
||||
else
|
||||
'public'
|
||||
end
|
||||
user_log_str(current_user)
|
||||
end
|
||||
|
||||
def depp_current_user
|
||||
|
@ -74,11 +66,8 @@ class ApplicationController < ActionController::Base
|
|||
)
|
||||
end
|
||||
|
||||
def api_user_log_str(user)
|
||||
if user.present?
|
||||
"#{user.id}-api-#{user.username}"
|
||||
else
|
||||
'api-public'
|
||||
end
|
||||
def user_log_str(user)
|
||||
return 'public' if user.nil?
|
||||
"#{user.id}-#{user.class}: #{user.username}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -120,7 +120,7 @@ class EppController < ApplicationController
|
|||
@current_user ||= ApiUser.find_by_id(epp_session[:api_user_id])
|
||||
# by default PaperTrail uses before filter and at that
|
||||
# time current_user is not yet present
|
||||
::PaperTrail.whodunnit = api_user_log_str(@current_user)
|
||||
::PaperTrail.whodunnit = user_log_str(@current_user)
|
||||
::PaperSession.session = epp_session.session_id if epp_session.session_id.present?
|
||||
@current_user
|
||||
end
|
||||
|
@ -350,6 +350,7 @@ class EppController < ApplicationController
|
|||
# rubocop: enable Style/PredicateName
|
||||
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
def write_to_epp_log
|
||||
# return nil if EPP_LOG_ENABLED
|
||||
request_command = params[:command] || params[:action] # error receives :command, other methods receive :action
|
||||
|
@ -366,12 +367,13 @@ class EppController < ApplicationController
|
|||
request_successful: epp_errors.empty?,
|
||||
request_object: params[:epp_object_type],
|
||||
response: @response,
|
||||
api_user_name: api_user_log_str(@api_user || current_user),
|
||||
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),
|
||||
ip: request.ip
|
||||
})
|
||||
end
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
|
||||
def iptables_counter_update
|
||||
return if ENV['iptables_counter_enabled'].blank? && ENV['iptables_counter_enabled'] != 'true'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue