开发者

Restful authentication + Facebook connect - User model redesign

开发者 https://www.devze.com 2022-12-27 16:52 出处:网络
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 co

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)?

  1. Refactor all validations (with :unless => :is_facebook_user), put conditions on observers, etc.

  2. Implement STI on User table (and have StandardUser / FacebookUser, each with custom authentication modules)

  3. User table having polymorphic reference to standard_user and facebook_user

  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消