1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

adding the hooks to mock request call and mock callback call

This commit is contained in:
Bill Cromie 2013-02-26 12:58:13 -05:00
parent e9e8a6a0d2
commit 8c1e27cbb0

View file

@ -197,11 +197,11 @@ module OmniAuth
log :info, "Request phase initiated." log :info, "Request phase initiated."
OmniAuth.config.on_request_hook.call(self.env)
#store query params from the request url, extracted in the callback_phase #store query params from the request url, extracted in the callback_phase
session['omniauth.params'] = request.params session['omniauth.params'] = request.params
OmniAuth.config.on_request_hook.call(self.env)
if options.form.respond_to?(:call) if options.form.respond_to?(:call)
log :info, "Rendering form from supplied Rack endpoint." log :info, "Rendering form from supplied Rack endpoint."
options.form.call(env) options.form.call(env)
@ -221,11 +221,11 @@ module OmniAuth
# Performs the steps necessary to run the callback phase of a strategy. # Performs the steps necessary to run the callback phase of a strategy.
def callback_call def callback_call
setup_phase setup_phase
OmniAuth.config.on_callback_hook.call(self.env)
log :info, "Callback phase initiated." log :info, "Callback phase initiated."
@env['omniauth.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == '' @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
@env['omniauth.params'] = session.delete('omniauth.params') || {} @env['omniauth.params'] = session.delete('omniauth.params') || {}
OmniAuth.config.on_callback_hook.call(@env)
callback_phase callback_phase
end end
@ -272,7 +272,7 @@ module OmniAuth
setup_phase setup_phase
session['omniauth.params'] = request.params session['omniauth.params'] = request.params
OmniAuth.config.on_request_hook.call(self.env)
if request.params['origin'] if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin'] @env['rack.session']['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/) elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@ -291,6 +291,7 @@ module OmniAuth
@env['omniauth.params'] = session.delete('omniauth.params') || {} @env['omniauth.params'] = session.delete('omniauth.params') || {}
@env['omniauth.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == '' @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
OmniAuth.config.on_callback_hook.call(@env)
call_app! call_app!
end end
end end