I am using authlogic and omniauth for authentication in my Rails 3.0.10 app.
However when I get the callback from the omniauth provider, I am not able to create a new user session so as to sign in the user.
In other responses (and even in the authlogic docs), it says that using UserSession.create(@user, true) should be able to create and persist a new session.
However, this does not work for me. It only works if the @user has a password in the database (by inserting a password directly in the db).
But there is no password when using third-party authentication providers, hence I cannot sign in users.
Any ideas how to sign in a user without a password in authlogic?
Thanks.
You can do something like this in your
Usermodel:externally_authenticated?is just a method on the user that checks what is providing the user information, and if it’s one of the omniauth providers, returns true.