I''m having problems with Simple Registration Extension with the Ruby
OpenID Login Generator. The code executes without error; but the
provider apparently returns only the sreg.email field, and none of the
others (e.g., sreg.gender, sreg.postcode, etc).
I''m using MyOpenID.com as the provider as they''ve announced
support
for Simple Registration Extension.
Here is the code segment from the openid_account_controller/complete
method (where the user is create and the extended data is append):
# create user object if one does not exist
if @user.nil ?
registration_info = response.extension_response(''sreg'')
@user = User.new(:openid_url => response.identity_url)
@user.email = registration_info[''email'']
@user.gender = registration_info[''gender'']
@user.save
end
The code executes without any errors. However, when I check the user
table, *only* the email field is populated; the gender field is not.
Any idea what may be causing the problem? Thx,
Dondi.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Michael Wang
2007-Mar-19 02:05 UTC
Re: Problem with MyOpenID.com Simple Registration Extension
Dondi wrote:> I''m having problems with Simple Registration Extension with the Ruby > OpenID Login Generator. The code executes without error; but the > provider apparently returns only the sreg.email field, and none of the > others (e.g., sreg.gender, sreg.postcode, etc). > > I''m using MyOpenID.com as the provider as they''ve announced support > for Simple Registration Extension. > > Here is the code segment from the openid_account_controller/complete > method (where the user is create and the extended data is append): > > # create user object if one does not exist > > if @user.nil ? > registration_info = response.extension_response(''sreg'') > @user = User.new(:openid_url => response.identity_url) > @user.email = registration_info[''email''] > @user.gender = registration_info[''gender''] > @user.save > end > > The code executes without any errors. However, when I check the user > table, *only* the email field is populated; the gender field is not. > > Any idea what may be causing the problem? Thx,I haven''t used that generator before but presumably registration_info[''gender''] is returning "" or nil. Add something like this to your code: if @user.nil? registration_info = response.extension_response(''sreg'') logger.debug("registration_info: #{registration_info.inspect}") and see what the values are that are being set in the registration_info hash. Perhaps your form has some errors in it. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Michael. The problem was with my ''Login'' method. I
changed
the following:
def login
openid_url = @params[:openid_url]
if @request.post?
request = consumer.begin(openid_url)
case request.status
when OpenID::SUCCESS
#request additional profile data: email, gender, state
request.add_extension_arg(''sreg'',''required'',''email,
gender,
postcode'')
...
To this:
def login
openid_url = @params[:openid_url]
if @request.post?
request = consumer.begin(openid_url)
case request.status
when OpenID::SUCCESS
#request additional profile data: email, gender, state
unless User.find_by_openid_url(request.identity_url)
request.add_extension_arg(''sreg'',
''required'',
''email,gender,postcode'')
end
...
The conditional request (via ''unless User.Find_...'') is
obviously
better coding; but I''m at a loss as to why the latter works, and why
the former didn''t since the
''request.add_extension_arg(...)'' statement
is identical. ???
On Mar 18, 9:05 pm, Michael Wang
<rails-u...-JtyympAsP2K7zZZRDBGcUA@public.gmane.org>
wrote:> Dondi wrote:
> > I''m having problems with Simple Registration Extension with
the Ruby
> > OpenID Login Generator. The code executes without error; but the
> > provider apparently returns only the sreg.email field, and none of the
> > others (e.g., sreg.gender, sreg.postcode, etc).
>
> > I''m using MyOpenID.com as the provider as they''ve
announced support
> > for Simple Registration Extension.
>
> > Here is the code segment from the openid_account_controller/complete
> > method (where the user is create and the extended data is append):
>
> > # create user object if one does not exist
>
> > if @user.nil ?
> > registration_info =
response.extension_response(''sreg'')
> > @user = User.new(:openid_url => response.identity_url)
> > @user.email = registration_info[''email'']
> > @user.gender = registration_info[''gender'']
> > @user.save
> > end
>
> > The code executes without any errors. However, when I check the user
> > table, *only* the email field is populated; the gender field is not.
>
> > Any idea what may be causing the problem? Thx,
>
> I haven''t used that generator before but presumably
> registration_info[''gender''] is returning "" or
nil.
>
> Add something like this to your code:
>
> if @user.nil?
> registration_info =
response.extension_response(''sreg'')
> logger.debug("registration_info:
#{registration_info.inspect}")
>
> and see what the values are that are being set in the registration_info
> hash. Perhaps your form has some errors in it.
>
> --
> Michael Wang
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---