Engin Erdogan
Engin Erdogan

Reputation: 631

Set a password after creating an account with Omniauth (Rails + Devise)

How can I let users set passwords once they create an account through Omniauth? Omniauth creates a stub password during registration, but the user does not know what that password is, therefore cannot change it from the edit user page.

I tried to override the edit form with the instructions here: How To: Allow users to edit their account without providing a password. I was able to change the encrypted password in the db, but cannot log in with the new password, and weirdly enough, I do not see any errors in the console during log in failure.

Any ideas?

I am using Rails 3.0.7 and Devise 1.4.8. My sign-in/sign-up code is based on the standard Omniauth+Devise tutorial.

Upvotes: 8

Views: 786

Answers (1)

Aymeric Bouzy aybbyk
Aymeric Bouzy aybbyk

Reputation: 2251

Omniauth only provides you with information on a remote user, with the guaranty that this user is connected to the provider. You then have three options :

  • create a user with that information, and set fields that are not specified with default method (which is what you did for password)
  • use that information to prefill devise sign up form (self.new_with_session as described in your tutorial) and let users create their account themselves, filling in the missing fields (such as password)
  • store the omniauth information in a session (or cookie), redirect your user to a form with the missing fields, and use both form information and session information to create your new user.

Upvotes: 0

Related Questions