Merge pull request #4531 from betagouv/fix_4529
Log l'email du super admin lors des actions dans le manager
This commit is contained in:
commit
0d8e7f956f
3 changed files with 48 additions and 0 deletions
|
@ -141,6 +141,8 @@ class ApplicationController < ActionController::Base
|
|||
Raven.user_context(sentry_user)
|
||||
end
|
||||
|
||||
# private method called by rails fwk
|
||||
# see https://github.com/roidrage/lograge
|
||||
def append_info_to_payload(payload)
|
||||
super
|
||||
|
||||
|
|
|
@ -19,5 +19,29 @@ module Manager
|
|||
redirect_to manager_sign_in_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# private method called by rails fwk
|
||||
# see https://github.com/roidrage/lograge
|
||||
def append_info_to_payload(payload)
|
||||
super
|
||||
|
||||
payload.merge!({
|
||||
user_agent: request.user_agent,
|
||||
user_id: current_user&.id,
|
||||
user_email: current_user&.email
|
||||
}.compact)
|
||||
|
||||
if browser.known?
|
||||
payload.merge!({
|
||||
browser: browser.name,
|
||||
browser_version: browser.version.to_s,
|
||||
platform: browser.platform.name
|
||||
})
|
||||
end
|
||||
|
||||
payload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
22
spec/controllers/manager/application_controller_spec.rb
Normal file
22
spec/controllers/manager/application_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
describe Manager::ApplicationController, type: :controller do
|
||||
describe 'append_info_to_payload' do
|
||||
let(:current_user) { create(:administration) }
|
||||
let(:payload) { {} }
|
||||
|
||||
before do
|
||||
allow(@controller).to receive(:current_user).and_return(current_user)
|
||||
@controller.send(:append_info_to_payload, payload)
|
||||
end
|
||||
|
||||
it do
|
||||
[:db_runtime, :view_runtime, :variant, :rendered_format].each do |key|
|
||||
payload.delete(key)
|
||||
end
|
||||
expect(payload).to eq({
|
||||
user_agent: 'Rails Testing',
|
||||
user_id: current_user.id,
|
||||
user_email: current_user.email
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue