Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't create an AX extension object unless necessary

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...
commit bcb8c9b7e808c15b055d7b2dce3af06dbd155d29 1 parent 8572b23
@sheltond sheltond authored josh committed
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/rack/openid.rb
View
15 lib/rack/openid.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.