8

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:

  1. User signs in with twitter
  2. User is presented with an email form
  3. User needs to confirm his/her email
  4. 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!

xjq233p_1
  • 7,810
  • 11
  • 61
  • 107

2 Answers2

3

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])
emrahbasman
  • 2,003
  • 10
  • 19
1

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.

twe4ked
  • 2,832
  • 21
  • 24
  • You know devise now allows twitter integration out of the box right? https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview I – xjq233p_1 Sep 18 '11 at 07:35
  • Sorry, that's just how I did it. I'm sure looking at the code implemented in the tutorial you could work something out. – twe4ked Sep 18 '11 at 07:42
  • The only hesitation I have with his approach is that he is using Authentications model rather than Devise's session model – xjq233p_1 Sep 18 '11 at 07:45