views:

276

answers:

2

I am trying to enable openid authentication on my website as well as use auto_register feature of latest authlogic_openid add-on.

Everything works fine until second login. The first time user is created and logged in, but after I logout and try logging in into the system with same OpenID identifier I get user registration form with errors saying that username and other fields are already taken and the form is prefilled with values of earlier data passed with openid.

Everything is implemented by authlogic/authlogic openid tutorial except for the user session model with new auto_register call:

class UserSession < Authlogic::Session::Base
  auto_register
end

Any help much appreciated!

+1  A: 

It seems like you're registering the users twice. The OpenID plugin doesn't know whether or not a user has been registered it just does SREG every time if auto_register is true. Rather than calling auto_register every time you could look up the user by openid_identifier and send auto_register(true) if they're a new user.

britt
i will definitely try this approach!
Eimantas
A: 

I've found http://github.com/gaizka/authlogic_openid

His version of the Authlogic Open ID extension seems to work with the auto_register feature... although I can't get it to capture the emails correctly from SREG (works with regular registration).

There's a demo of it working here:

http://big-glow-mama.heroku.com/

http://github.com/holden/authlogic_openid_selector_example/tree/with-facebook/

holden