Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/omniauth/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def mock_call!(env)
def mock_request_call
setup_phase

session['omniauth.params'] = request.params

if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
Expand All @@ -276,7 +278,7 @@ def mock_callback_call
fail!(mocked_auth)
else
@env['omniauth.auth'] = mocked_auth
@env['omniauth.params'] = session.delete('query_params') || {}
@env['omniauth.params'] = session.delete('omniauth.params') || {}
@env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
call_app!
Expand Down
14 changes: 14 additions & 0 deletions spec/omniauth/strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,20 @@ def make_env(path = '/auth/test', props = {})
strategy.env['omniauth.origin'].should == 'http://example.com/origin'
end

it 'should set omniauth.params on the request phase' do
OmniAuth.config.mock_auth[:test] = {}

strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'foo=bar'))
strategy.env['rack.session']['omniauth.params'].should == {'foo' => 'bar'}
end

it 'should turn omniauth.params into an env variable on the callback phase' do
OmniAuth.config.mock_auth[:test] = {}

strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.params' => {'foo' => 'bar'}}))
strategy.env['omniauth.params'].should == {'foo' => 'bar'}
end

after do
OmniAuth.config.test_mode = false
end
Expand Down