Preserve query string in callback url

This commit is contained in:
Wes Gibbs 2010-12-11 08:38:01 -05:00
parent 24fa614724
commit f57712e7fb
2 changed files with 30 additions and 1 deletions

View File

@ -60,6 +60,10 @@ module OmniAuth
def callback_path
options[:callback_path] || "#{path_prefix}/#{name}/callback"
end
def query_string
request.query_string.empty? ? "" : "?#{request.query_string}"
end
def call_app!
@env['omniauth.strategy'] = self
@ -82,7 +86,7 @@ module OmniAuth
end
def callback_url
full_host + callback_path
full_host + callback_path + query_string
end
def session

View File

@ -47,6 +47,14 @@ describe OmniAuth::Strategy do
strategy.callback_url.should == 'http://example.com/auth/test/callback'
end
it 'preserves the query parameters' do
strategy.stub(:full_host).and_return('http://example.com')
begin
strategy.call({'PATH_INFO' => '/auth/test', 'QUERY_STRING' => 'id=5'})
rescue RuntimeError; end
strategy.callback_url.should == 'http://example.com/auth/test/callback?id=5'
end
end
end
@ -79,6 +87,15 @@ describe OmniAuth::Strategy do
strategy.callback_url.should == 'http://example.com/radical'
end
it 'preserves the query parameters' do
@options = {:callback_path => '/radical'}
strategy.stub(:full_host).and_return('http://example.com')
begin
strategy.call({'QUERY_STRING' => 'id=5'})
rescue RuntimeError; end
strategy.callback_url.should == 'http://example.com/radical?id=5'
end
end
end
@ -103,6 +120,14 @@ describe OmniAuth::Strategy do
strategy.callback_url.should == 'http://example.com/wowzers/test/callback'
end
it 'preserves the query parameters' do
strategy.stub(:full_host).and_return('http://example.com')
begin
strategy.call({'PATH_INFO' => '/wowzers/test', 'QUERY_STRING' => 'id=5'})
rescue RuntimeError; end
strategy.callback_url.should == 'http://example.com/wowzers/test/callback?id=5'
end
end
end
end