I have a site with Restful authentication as authentication plugin. I need to integrate Facebook connect. Facebook does not provide email address for the user (maybe only if user agrees if), and of course does not provide a password.
The main issue is that the User model has a lot of validates_**
on those 2 fields (from Restful authentication modules).
Another little issue would be开发者_JAVA百科 that we already have a lot of code (observers sending emails after user creation, etc etc) that depends on email address.
The solution present in the facebook_connect tutorials was to save the user model bypassing validations, but this is sooo wrong..
How would you redesign the User model to include any/both of the authentication methods(standard and/or facebook_connect)?
Refactor all validations (with :unless => :is_facebook_user), put conditions on observers, etc.
Implement STI on User table (and have StandardUser / FacebookUser, each with custom authentication modules)
User table having polymorphic reference to standard_user and facebook_user
Other ideea
Please notice that the functionality to link a 'standard' account to a 'facebook' account is also required, which complicates things.
References:
http://crazyviraj.blogspot.com/2010/01/test-cases-for-basic-facebook-connect.html
http://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/comment-page-1/
A good example to get your started here.
精彩评论