At last, Attribute Exchange for OpenID worked out to properly provide names from Google.
This commit is contained in:
Родитель
cc1112f5fc
Коммит
bbc6580da2
|
@ -36,7 +36,7 @@ module OmniAuth
|
|||
def initialize(app, store = nil, options = {})
|
||||
super(app, options[:name] || :open_id)
|
||||
@options = options
|
||||
@options[:required] ||= [AX[:email], AX[:first_name], AX[:last_name], 'email', 'fullname']
|
||||
@options[:required] ||= [AX[:email], AX[:name], AX[:first_name], AX[:last_name], 'email', 'fullname']
|
||||
@options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
|
||||
@store = store
|
||||
end
|
||||
|
@ -48,7 +48,8 @@ module OmniAuth
|
|||
:identifier => identifier,
|
||||
:return_to => callback_url,
|
||||
:required => @options[:required],
|
||||
:optional => @options[:optional]
|
||||
:optional => @options[:optional],
|
||||
:method => 'post'
|
||||
)}, []]}
|
||||
end
|
||||
|
||||
|
@ -122,11 +123,13 @@ module OmniAuth
|
|||
ax = ::OpenID::AX::FetchResponse.from_success_response(response)
|
||||
return {} unless ax
|
||||
{
|
||||
'email' => ax[AX[:email]],
|
||||
'name' => ax[AX[:name]],
|
||||
'location' => ("#{ax[AX[:city]]}, #{ax[AX[:state]]}" if Array(ax[AX[:city]]).any? && Array(ax[AX[:state]]).any?),
|
||||
'nickname' => ax[AX[:nickname]],
|
||||
'urls' => ({'Website' => Array(ax[AX[:website]]).first} if Array(ax[AX[:website]]).any?)
|
||||
'email' => ax.get_single(AX[:email]),
|
||||
'first_name' => ax.get_single(AX[:first_name]),
|
||||
'last_name' => ax.get_single(AX[:last_name]),
|
||||
'name' => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(' ')),
|
||||
'location' => ("#{ax.get_single(AX[:city])}, #{ax.get_single(AX[:state])}" if Array(ax.get_single(AX[:city])).any? && Array(ax.get_single(AX[:state])).any?),
|
||||
'nickname' => ax.get_single(AX[:nickname]),
|
||||
'urls' => ({'Website' => Array(ax.get_single(AX[:website])).first} if Array(ax.get_single(AX[:website])).any?)
|
||||
}.inject({}){|h,(k,v)| h[k] = Array(v).first; h}.reject{|k,v| v.nil? || v == ''}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|||
gem.files = Dir.glob("{lib}/**/*") + %w(LICENSE.rdoc CHANGELOG.rdoc)
|
||||
|
||||
gem.add_dependency 'oa-core', version
|
||||
gem.add_dependency 'rack-openid', '~> 1.1.1'
|
||||
gem.add_dependency 'rack-openid', '~> 1.2.0'
|
||||
gem.add_dependency 'ruby-openid-apps-discovery'
|
||||
|
||||
eval File.read(File.join(File.dirname(__FILE__), '../development_dependencies.rb'))
|
||||
|
|
Загрузка…
Ссылка в новой задаче