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

Merge pull request #554 from toyokazu/master

A request to insert env['SCRIPT_NAME'] before on_failure new_path
This commit is contained in:
Michael Bleigh 2012-01-17 13:00:50 -08:00
commit ce9b5b088f
2 changed files with 13 additions and 1 deletions

View file

@ -24,7 +24,7 @@ module OmniAuth
:path_prefix => '/auth',
:on_failure => Proc.new do |env|
message_key = env['omniauth.error.type']
new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
[302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
end,
:form_css => Form::DEFAULT_CSS,

View file

@ -496,6 +496,18 @@ describe OmniAuth::Strategy do
response[1]['Location'].should == '/sub_uri/auth/test/callback'
end
it 'should redirect on failure' do
response = OmniAuth.config.on_failure.call(make_env('/auth/test', 'omniauth.error.type' => 'error'))
response[0].should == 302
response[1]['Location'].should == '/auth/failure?message=error'
end
it 'should respect SCRIPT_NAME (a.k.a. BaseURI) on failure' do
response = OmniAuth.config.on_failure.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri', 'omniauth.error.type' => 'error'))
response[0].should == 302
response[1]['Location'].should == '/sub_uri/auth/failure?message=error'
end
it 'should be case insensitive on callback path' do
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
end