Skip to content

Commit

Permalink
Merge branch 'master' of github.com:intridea/omniauth
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed May 7, 2011
2 parents d259340 + fefbffd commit e704cd8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion oa-core/lib/omniauth/strategy.rb
Expand Up @@ -95,7 +95,7 @@ def mock_request_call
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
end
redirect(callback_path)
redirect(script_name + callback_path)
end

def mock_callback_call
Expand Down
5 changes: 5 additions & 0 deletions oa-core/spec/omniauth/strategy_spec.rb
Expand Up @@ -258,6 +258,11 @@ def make_env(path = '/auth/test', props = {})
strategy.call(make_env('/AUTH/Test'))[0].should == 302
end

it 'should respect SCRIPT_NAME (a.k.a. BaseURI)' do
response = strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
response[1]['Location'].should == '/sub_uri/auth/test/callback'
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
Expand Down
2 changes: 1 addition & 1 deletion oa-oauth/lib/omniauth/strategies/facebook.rb
Expand Up @@ -45,7 +45,7 @@ def facebook_session

def user_info
{
'nickname' => user_data["link"].split('/').last,
'nickname' => user_data["username"],
'email' => (user_data["email"] if user_data["email"]),
'first_name' => user_data["first_name"],
'last_name' => user_data["last_name"],
Expand Down
11 changes: 7 additions & 4 deletions oa-oauth/lib/omniauth/strategies/linked_in.rb
Expand Up @@ -40,10 +40,13 @@ def user_hash(access_token)
'description' => person['headline'],
'public_profile_url' => person['public_profile_url']
}
hash['urls']={}
person['member_url_resources']['member_url'].each do |url|
hash['urls']["#{url['name']}"]=url['url']
end
hash['urls']={}
member_urls = person['member_url_resources']['member_url']
if (!member_urls.nil?) and (!member_urls.empty?)
[member_urls].flatten.each do |url|
hash['urls']["#{url['name']}"]=url['url']
end
end
hash['urls']['LinkedIn'] = person['public_profile_url']
hash['name'] = "#{hash['first_name']} #{hash['last_name']}"
hash
Expand Down
4 changes: 3 additions & 1 deletion oa-oauth/lib/omniauth/strategies/oauth2.rb
Expand Up @@ -80,6 +80,8 @@ def callback_phase
fail!(:invalid_credentials, e)
rescue ::MultiJson::DecodeError => e
fail!(:invalid_response, e)
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
fail!(:timeout, e)
end

def build_access_token
Expand All @@ -89,7 +91,7 @@ def build_access_token

def auth_hash
credentials = {'token' => @access_token.token}
credentials.merge('refresh_token' => @access_token.refresh_token) if @access_token.expires?
credentials.merge!('refresh_token' => @access_token.refresh_token) if @access_token.expires?

OmniAuth::Utils.deep_merge(super, {'credentials' => credentials})
end
Expand Down

0 comments on commit e704cd8

Please sign in to comment.