Register with facebook/twitter, but login with "local" login detail
I have an invite-开发者_StackOverflowonly website. And I would like the users to have the possibility to register with either my own register form, or that they can register with Facebook/Twitter - after they get an invitation from an existing user.
Once they are registered, I would like them to only use my website's login form to log in. The question is: what is the best way to approach this, is this a good idea to start with?
What I've done in the past is create 2 tables (assuming you are using a standard SQL database): one representing accounts and one representing authorization techniques. You can then create a row in the account table for a user and then create a separate row in the authorization table that indicates whether the auth is username/password (in which case the row has the password hash) or facebook (in which case it has the fbuid). You can then look up the account from the auth table when a uer chooses their login method.
精彩评论