mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
insert env['SCRIPT_NAME'] before on_failure path
handle sub_uri (a.k.a. BaseURI) at on_failure
This commit is contained in:
parent
2b2384bdf0
commit
9022d66cea
2 changed files with 13 additions and 1 deletions
|
@ -24,7 +24,7 @@ module OmniAuth
|
||||||
:path_prefix => '/auth',
|
:path_prefix => '/auth',
|
||||||
:on_failure => Proc.new do |env|
|
:on_failure => Proc.new do |env|
|
||||||
message_key = env['omniauth.error.type']
|
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'}, []]
|
[302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
|
||||||
end,
|
end,
|
||||||
:form_css => Form::DEFAULT_CSS,
|
:form_css => Form::DEFAULT_CSS,
|
||||||
|
|
|
@ -496,6 +496,18 @@ describe OmniAuth::Strategy do
|
||||||
response[1]['Location'].should == '/sub_uri/auth/test/callback'
|
response[1]['Location'].should == '/sub_uri/auth/test/callback'
|
||||||
end
|
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
|
it 'should be case insensitive on callback path' do
|
||||||
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
|
strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue