Try the updated version and email me if you continue to have problems
with it:
http://www.bencurtis.com/archives/2007/07/openid-sample-application-
updated/
--
Benjamin Curtis
http://www.bencurtis.com/ -- blog
http://agilewebdevelopment.com/guides/ -- Rails HOWTOs
On Sep 1, 2007, at 6:31 PM, Mister Yu wrote:
>
> Hello all,
>
> i was trying to follow this tutorial(
> http://www.bencurtis.com/archives/2007/03/rails-openid-and-acts-as-
> authenticated/
> ) and the README file to add OpenID support to my login system.
>
> i successfully got to the point where it can login users with OpenID,
> without requiring some informations from "simple-registration-
> extension" (nickname, email, etc)
>
> once i can login user with OpenID, i followed the README file of the
> plugin, which change the "open_id_authentication(identity_url)"
into:
>
> ***************************
> def open_id_authentication(identity_url)
> # Pass optional :required and :optional keys to specify what
> sreg fields you want.
> # Be sure to yield registration, a third argument in the
> #authenticate_with_open_id block.
> authenticate_with_open_id(identity_url,
> :required => [ :nickname, :email ]) do |status,
> identity_url, registration|
> case status
> when :missing
> failed_login "Sorry, the OpenID server couldn''t
be found"
> when :canceled
> failed_login "OpenID verification was canceled"
> when :failed
> failed_login "Sorry, the OpenID verification failed"
> when :successful
> if @current_user >
@account.users.find_by_identity_url(identity_url)
> assign_registration_attributes!(registration)
>
> if current_user.save
> successful_login
> else
> failed_login "Your OpenID profile registration failed:
> " +
> @current_user.errors.full_messages.to_sentence
> end
> else
> failed_login "Sorry, no user by that identity URL
> exists"
> end
> end
> end
> end
> ***************************
> also added:
> def assign_registration_attributes!(registration)
> model_to_registration_mapping.each do |model_attribute,
> registration_attribute|
> unless registration[registration_attribute].blank?
> @current_user.send("#{model_attribute}=",
> registration[registration_attribute])
> end
> end
> end
>
> def model_to_registration_mapping
> { :login => ''nickname'', :email =>
''email'' }
> end
> ***************************
> and changed:
> def login
> if using_open_id?
> open_id_authentication(params[:openid_url])
> elsif params[:login]
> password_authentication(params[:login], params[:password])
> end
> end
>
> now when i login with an OpenID, it takes me to the provider, provider
> prompts that it requires email, nickname, after i hit ALLOW ONCE, it
> redirects me back to the login page, and the strange thing is, it has
> no error message or warning messages. and the url is not saved into
> the database. can some one give me some hints?
>
> here''s the development log, hope it helps:
> *************
>
> Processing AccountController#login (for 127.0.0.1 at 2007-09-02
> 02:15:39) [POST]
> Session ID: 3cb1bf432832ad821b4334d2d61b9bea
> Parameters: {"commit"=>"Log in",
"openid_url"=>"http://
> erv2.myopenid.com/", "action"=>"login",
"controller"=>"account",
> "login"=>"", "password"=>""}
> [4;36;1mOpenIdAuthentication::Nonce Load (0.000000) [0m
> [0;1mSELECT * FROM open_id_authentication_nonces WHERE
> (open_id_authentication_nonces.`nonce` = ''g9GVDNDr'')
LIMIT 1 [0m
> [4;35;1mSQL (0.000000) [0m [0mBEGIN [0m
> [4;36;1mSQL (0.000000) [0m [0;1mINSERT INTO
> open_id_authentication_nonces (`created`, `nonce`) VALUES(1188695740,
> ''g9GVDNDr'') [0m
> [4;35;1mSQL (0.015000) [0m [0mCOMMIT [0m
> [4;36;1mOpenIdAuthentication::Association Load (0.016000) [0m
> [0;1mSELECT * FROM open_id_authentication_associations WHERE
> (open_id_authentication_associations.`server_url` = ''http://
> www.myopenid.com/server'') [0m
> Redirected to
> http://www.myopenid.com/server?
> openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Flocalhost%
> 3A3000%2Faccount%2Flogin%3Fopen_id_complete%3D1%26nonce%3Dg9GVDNDr%
> 26nonce%3Dg9GVDNDr&openid.sreg.required=nickname%
> 2Cemail&openid.trust_root=http%3A%2F%2Flocalhost%3A3000%
> 2F&openid.identity=http%3A%2F%2Ferv2.myopenid.com%
> 2F&openid.assoc_handle=%7BHMAC-SHA1%7D%7B46d9e682%7D%7B7JwLmA%3D%3D%7D
> Completed in 0.42200 (2 reqs/sec) | DB: 0.03100 (7%) | 302 Found
> [http://localhost/account/login]
>
>
> Processing AccountController#login (for 127.0.0.1 at 2007-09-02
> 02:17:05) [GET]
> Session ID: 3cb1bf432832ad821b4334d2d61b9bea
> Parameters: {"openid.sreg.nickname"=>"erv2",
> "openid.mode"=>"id_res",
"openid.return_to"=>"http://localhost:3000/
>
account/login?open_id_complete=1&nonce=g9GVDNDr&nonce=g9GVDNDr",
> "openid.sig"=>"H1uytnVNpb3zeCmsdMdqMFWygzI=",
>
"openid.op_endpoint"=>"http://www.myopenid.com/server",
>
"openid.response_nonce"=>"2007-09-02T01:16:57ZfnpIUD",
> "action"=>"login",
"openid.sreg.email"=>"earrth2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org",
> "controller"=>"account",
"openid.identity"=>"http://
> erv2.myopenid.com/", "open_id_complete"=>"1",
"nonce"=>"g9GVDNDr",
>
"openid.assoc_handle"=>"{HMAC-SHA1}{46d9e682}{7JwLmA==}",
>
"openid.signed"=>"assoc_handle,identity,mode,op_endpoint,response_nonc
> e,return_to,signed,sreg.email,sreg.nickname"}
> [4;35;1mOpenIdAuthentication::Association Load (0.000000) [0m
> [0mSELECT * FROM open_id_authentication_associations WHERE
> (open_id_authentication_associations.`handle` =
''{HMAC-SHA1}{46d9e682}
> {7JwLmA==}'' AND open_id_authentication_associations.`server_url`
> ''http://www.myopenid.com/server'') [0m
> [4;36;1mOpenIdAuthentication::Nonce Load (0.000000) [0m
> [0;1mSELECT * FROM open_id_authentication_nonces WHERE
> (open_id_authentication_nonces.`nonce` = ''g9GVDNDr'')
LIMIT 1 [0m
> [4;35;1mSQL (0.000000) [0m [0mBEGIN [0m
> [4;36;1mOpenIdAuthentication::Nonce Destroy (0.000000) [0m [0;1m
> DELETE FROM open_id_authentication_nonces
> WHERE `id` = 10
> [0m
> [4;35;1mSQL (0.032000) [0m [0mCOMMIT [0m
> Rendering within layouts/account
> Rendering account/login
> Completed in 0.06300 (15 reqs/sec) | Rendering: 0.00000 (0%) | DB:
> 0.03200 (50%) | 200 OK [http://localhost/account/login?
>
open_id_complete=1&nonce=g9GVDNDr&nonce=g9GVDNDr&openid.assoc_handle>
%7BHMAC-SHA1%7D%7B46d9e682%7D%7B7JwLmA%3D%3D%7D&openid.identity=http
> %3A
>
%2F%2Ferv2.myopenid.com%2F&openid.mode=id_res&openid.op_endpoint=http
> %3A%2F%2Fwww.myopenid.com
> %2Fserver&openid.response_nonce=2007-09-02T01%3A16%
> 3A57ZfnpIUD&openid.return_to=http
> %3A%2F%2Flocalhost%3A3000%2Faccount%2Flogin%3Fopen_id_complete
> %3D1%26nonce%3Dg9GVDNDr%26nonce
> %3Dg9GVDNDr&openid.sig=H1uytnVNpb3zeCmsdMdqMFWygzI
> %3D&openid.signed=assoc_handle%2Cidentity%2Cmode%2Cop_endpoint
> %2Cresponse_nonce%2Creturn_to%2Csigned%2Csreg.email
> %2Csreg.nickname&openid.sreg.email=earrth2%
> 40gmail.com&openid.sreg.nickname=erv2]
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---