Class: ProxES::Listener
- Inherits:
-
Object
- Object
- ProxES::Listener
- Defined in:
- lib/proxes/services/listener.rb
Instance Method Summary collapse
- #es_request_denied(request, exception = nil) ⇒ Object
- #es_request_failed(request, response) ⇒ Object
- #user_login(details) ⇒ Object
- #user_traits(request) ⇒ Object
Instance Method Details
#es_request_denied(request, exception = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/proxes/services/listener.rb', line 27 def es_request_denied(request, exception = nil) detail = request.detail detail = "#{detail} - #{exception.class}" if exception Ditty::Services::Logger.error exception if exception Ditty::AuditLog.create( user_traits(request).merge( action: :es_request_denied, user: request.user, details: detail ) ) end |
#es_request_failed(request, response) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/proxes/services/listener.rb', line 17 def es_request_failed(request, response) Ditty::AuditLog.create( user_traits(request).merge( action: :es_request_failed, user: request.user, details: "#{request.detail} > #{response[0]}" ) ) end |
#user_login(details) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/proxes/services/listener.rb', line 10 def user_login(details) target = details[:target] if target.request.session['omniauth.origin'].nil? && target.request.accept?('text/html') target.request.session['omniauth.origin'] = '/_proxes' end end |
#user_traits(request) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/proxes/services/listener.rb', line 40 def user_traits(request) browser = Browser.new(request.user_agent, accept_language: request.env['HTTP_ACCEPT_LANGUAGE']) { platform: browser.platform.name, device: browser.device.name, browser: browser.name, ip_address: request.ip } end |