lib/omniauth/strategies/open_id.rb in oa-openid-0.1.6 vs lib/omniauth/strategies/open_id.rb in oa-openid-0.2.0.beta1

- old
+ new

@@ -33,12 +33,12 @@ # @option options [Array] :required The identity fields that are required for the OpenID # request. May be an ActiveExchange schema URL or an sreg identifier. # @option options [Array] :optional The optional attributes for the OpenID request. May # be ActiveExchange or sreg. # @option options [Symbol, :open_id] :name The URL segment name for this provider. - def initialize(app, store = nil, options = {}) - super(app, options[:name] || :open_id) + def initialize(app, store = nil, options = {}, &block) + super(app, (options[:name] || :open_id), &block) @options = options @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 @@ -126,10 +126,10 @@ return {} unless ax { '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(' ')), + 'name' => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(' ')).strip, '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