DEV: add request data to the before_session_destroy event (#16905)

This commit is contained in:
Jean
2022-05-31 18:18:56 -04:00
committed by GitHub
parent 41fa278c00
commit 9ac85d6163
2 changed files with 17 additions and 1 deletions

View File

@ -2291,6 +2291,22 @@ describe SessionController do
ensure
DiscourseEvent.off(:before_session_destroy, &callback)
end
it 'includes ip and user agent in the before_session_destroy event params' do
callback_params = {}
callback = -> (data) { callback_params = data }
DiscourseEvent.on(:before_session_destroy, &callback)
user = sign_in(Fabricate(:user))
delete "/session/#{user.username}.json", xhr: true, headers: { HTTP_USER_AGENT: 'AwesomeBrowser' }
expect(callback_params[:user_agent]).to eq('AwesomeBrowser')
expect(callback_params[:client_ip]).to eq('127.0.0.1')
ensure
DiscourseEvent.off(:before_session_destroy, &callback)
end
end
describe '#one_time_password' do