I want to let users login to my website using their Facebook, or Twitter account, but if they don’t have one then to register a new account, and use the basic login of my site.
But how should my users table looks like:
My idea:
- id (primary, auto increment)
- username (in case of oauth login => ouath_provider+oauth_id, ex:fb_100001557958700)
- password (password choosed by user or randomly generated in case of oauth)
- name (name to display)
What do you think?
Or should I have 2 tables, 1 for basic login, and another 1 for oauth login? But then how users whill have unique ids?
Thanks in advance for comments.
In my experience, you are best storing your authorizations in one table, and your user data in the other.
authorizations:
users:
With this structure, if you want to allow the same user to login with both Twitter AND Facebook at some point in the future, that is also possible.