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

set hooks as nil and check for presence

This commit is contained in:
Tom Milewski 2013-09-02 15:30:32 -04:00
parent c3942078cf
commit a239ba2980
3 changed files with 8 additions and 9 deletions

View file

@ -34,9 +34,9 @@ module OmniAuth
:path_prefix => '/auth',
:on_failure => OmniAuth::FailureEndpoint,
:failure_raise_out_environments => ['development'],
:on_callback_hook =>Proc.new {|p|},
:on_options_hook=>Proc.new {|p| },
:on_request_hook=>Proc.new {|p| },
:on_callback_hook => nil,
:on_options_hook => nil,
:on_request_hook => nil,
:form_css => Form::DEFAULT_CSS,
:test_mode => false,
:logger => default_logger,

View file

@ -186,7 +186,7 @@ module OmniAuth
# Responds to an OPTIONS request.
def options_call
OmniAuth.config.on_options_hook.call(self.env)
OmniAuth.config.on_options_hook.call(self.env) if OmniAuth.config.on_options_hook
verbs = OmniAuth.config.allowed_request_methods.map(&:to_s).map(&:upcase).join(', ')
return [ 200, { 'Allow' => verbs }, [] ]
end
@ -200,7 +200,7 @@ module OmniAuth
#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)
OmniAuth.config.on_request_hook.call(self.env) if OmniAuth.config.on_request_hook
if options.form.respond_to?(:call)
log :info, "Rendering form from supplied Rack endpoint."
@ -225,7 +225,7 @@ module OmniAuth
@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)
OmniAuth.config.on_callback_hook.call(@env) if OmniAuth.config.on_callback_hook
callback_phase
end
@ -268,7 +268,7 @@ module OmniAuth
setup_phase
session['omniauth.params'] = request.params
OmniAuth.config.on_request_hook.call(self.env)
OmniAuth.config.on_request_hook.call(self.env) if OmniAuth.config.on_request_hook
if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@ -287,7 +287,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)
OmniAuth.config.on_callback_hook.call(@env) if OmniAuth.config.on_callback_hook
call_app!
end
end

View file

@ -605,7 +605,6 @@ describe OmniAuth::Strategy do
expect(strategy.env['foobar']).to eq('baz')
end
it "sets omniauth.params on the request phase" do
OmniAuth.config.mock_auth[:test] = {}