为网站用户添加facebook/twitter登录选项


Adding facebook/twitter login option to website users

用户的详细信息保存在名为user的数据库表中,其中我有字段username和password等。现在,我需要给用户额外的选项登录使用facebook和twitter。我知道如何处理这些身份验证,但我不能想到的是-

如何识别哪个FB用户帐户与哪个本地用户帐户相关?我该怎么做?

我不是在找代码,而是在找过程。我脑海中的过程大致如下-用户使用我网站的用户名和密码登录。然后他们可以添加FB或Twitter作为外部身份验证,当他们这样做时,我会要求他们登录FB。成功登录FB后,我在users表中保存了一些唯一的FB id(我不知道是哪个,因为还没有检查)。下次他们可以使用FB登录,因为我可以识别他们属于哪个本地记录。你会这样做吗?

你有什么建议?感谢您提前提供的意见。

PS-我将添加多个网络(如linkedin和其他网络),但目前仅限于fb和twitter。

实现这一点的一种方法是:@注册

1. Allow the user to register with Facebook, Twitter
2. Once the process has completed, redirect the user to create a username on your site
3. Using the email obtained from Facebook, Twitter, and username from local form, insert all this information into a db table.
4. This will allow referencing between FB, TW, and local usernames

创建一个相互关联的表,其中包含userid、facebook或twitter userid、身份验证类型(facebook或twitter)。