I want users to be able to login from any provider (facebook, google, etc) from my app and also to create an account with my server. What I want to figure out is the best way to construct a user model doing this.
For example,
A user logs in using facebook a new user record will be made and there will be a flag in the record telling me that the account is a facebook account. If the same user creates a standard account with my server and then logs back in using facebook, how shall I handle this? Is the best practice to merge/relate these two accounts with each other or to treat them as two different records?
Currently Im working on the same things. I will use these rules:
accounts.
params to compare.
About scheme: I create a table
users(id, username, email) anduser_data(id, user_id, email, service_id, service_name, service_type, is_active).service_idis a Provider-specific identifier,service_typeis a Provider name (google/facebook/etc), andservice_nameis a displayName from Provider’s site (may differs fromuser.username).service_id + service_typemust be unique.