authlogic openid auto_register feature tries to duplicate registration
-
07-07-2019 - |
Question
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!
Solution
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.
OTHER TIPS
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/