From 8c1e27cbb0ea1148832b74664fd5007195dbfa28 Mon Sep 17 00:00:00 2001 From: Bill Cromie Date: Tue, 26 Feb 2013 12:58:13 -0500 Subject: [PATCH] adding the hooks to mock request call and mock callback call --- lib/omniauth/strategy.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/omniauth/strategy.rb b/lib/omniauth/strategy.rb index 247f2a9..edf8cd7 100644 --- a/lib/omniauth/strategy.rb +++ b/lib/omniauth/strategy.rb @@ -197,11 +197,11 @@ module OmniAuth 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 session['omniauth.params'] = request.params + OmniAuth.config.on_request_hook.call(self.env) + if options.form.respond_to?(:call) log :info, "Rendering form from supplied Rack endpoint." options.form.call(env) @@ -221,11 +221,11 @@ module OmniAuth # Performs the steps necessary to run the callback phase of a strategy. def callback_call setup_phase - OmniAuth.config.on_callback_hook.call(self.env) log :info, "Callback phase initiated." @env['omniauth.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' @env['omniauth.params'] = session.delete('omniauth.params') || {} + OmniAuth.config.on_callback_hook.call(@env) callback_phase end @@ -272,7 +272,7 @@ module OmniAuth setup_phase session['omniauth.params'] = request.params - + OmniAuth.config.on_request_hook.call(self.env) if request.params['origin'] @env['rack.session']['omniauth.origin'] = request.params['origin'] 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.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' + OmniAuth.config.on_callback_hook.call(@env) call_app! end end