Skip to content

Commit

Permalink
Don't create an AX extension object unless necessary
Browse files Browse the repository at this point in the history
This is a workaround for a bug in the ruby-openid gem which outputs a
"mode" parameter even if there are no other values being queried. This
causes some providers (such as Google) to prompt the user differently
(for example, Google says "site X is requesting information from your
Google account" instead of just "sign in to site X with your Google
account").
  • Loading branch information
sheltond authored and josh committed Sep 13, 2010
1 parent 8572b23 commit bcb8c9b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/rack/openid.rb
Expand Up @@ -238,12 +238,19 @@ def add_attribute_exchange_fields(oidreq, fields)
axreq = ::OpenID::AX::FetchRequest.new

required = Array(fields['required']).select(&URL_FIELD_SELECTOR)
required.each { |field| axreq.add(::OpenID::AX::AttrInfo.new(field, nil, true)) }

optional = Array(fields['optional']).select(&URL_FIELD_SELECTOR)
optional.each { |field| axreq.add(::OpenID::AX::AttrInfo.new(field, nil, false)) }

oidreq.add_extension(axreq)
if required.any? || optional.any?
required.each do |field|
axreq.add(::OpenID::AX::AttrInfo.new(field, nil, true))
end

optional.each do |field|
axreq.add(::OpenID::AX::AttrInfo.new(field, nil, false))
end

oidreq.add_extension(axreq)
end
end

def add_oauth_fields(oidreq, fields)
Expand Down

0 comments on commit bcb8c9b

Please sign in to comment.