I have implemented twitter authentication with devise using something very similar to this: https://github.com/plataformatec/devise/wiki开发者_运维知识库/OmniAuth:-Overview
My question is, since twitter doesn't give you the email of the user, how can you direct the user back to the flow of:
- User signs in with twitter
- User is presented with an email form
- User needs to confirm his/her email
- clicking confirmation link sends user to site logged in
Devise pretty much takes care with #3 and #4. How should I structure my code to allow #2 to transit into #3 and #4?
Thanks!
Show new user form in twitter callback page. Store twitter token in hidden field. Then you can create new user in your controller and do what you want with the twitter token. User.create also sends confirmation email.
User.create(:email => params[:email], :password => params[:password], :password_confirmation => params[:password_confirmation])
Ryan Bates covers most of this in his screencast OmniAuth Part 2, to get the email confirmation all you need to do is add the confirmable
option to devise.
精彩评论