将通过 Facebook 连接登录的新用户链接到现有帐户
我最近通过 facebook connect 实现了登录。所以现在用户有两种方式登录该网站。注册帐户的旧方式和新方式(facebook connect)。
我想做的一件事是将新的 facebook connect 用户帐户链接到现有帐户(如果他们以旧方式登录)。
有人在这方面取得过成功吗?
I have recently implemented login to my via facebook connect. So now users have 2 ways of logging in to the site. The old way of registering an account and the new way (facebook connect).
One thing I would like to do is link a new facebook connect user account to existing accounts if they logged in the old way.
Has anyone had any success doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这是一个很好的问题,很多人都会从答案中受益。
您需要记住的是,只有经过 Facebook 授权才能链接的帐户才会被链接。您应该做的是在数据库中维护第二个关联帐户表,以便您知道谁是谁以及他们是否与 Facebook 关联。
您应该阅读此集成评论,它提供了很多有用的信息。
http://crazyviraj.blogspot.com/ 2010/01/test-cases-for-basic-facebook-connect.html
它并没有真正说明如何做事,但它确保您勾选了您应该做的所有方框。
IE:
还有更多
Very good question I think and lots of people will benefit from an answer.
What you need to remember is that accounts are only linked so long as they are authorised to be linked through Facebook. What you should do is maintain a second table of linked accounts in your database so that you know who is who and if they are linked with Facebook.
You should read this integration comment, it provides a lot of useful information.
http://crazyviraj.blogspot.com/2010/01/test-cases-for-basic-facebook-connect.html
It doesn't really say how to do things, but it makes sure you tick all the boxes of what you should be doing.
ie:
Any many more
您应该通过 fb connect 身份验证请求永久访问。完成此操作后,您将获得一个令牌,该令牌允许您访问某人的 Facebook 信息,并且该令牌不会过期,除非用户明确将您从权限列表中删除或更改他/她的密码。
获得令牌后,将该令牌与用户关联/在用户表中创建一个新字段来存储它。
要在用户未登录的情况下将用户与 Facebook 帐户关联,您可以尝试通过电子邮件进行匹配。它不是 100% 准确,但相当不错。 Facebook 不会以文本形式向您提供电子邮件地址,但您可以从 FQL 获取电子邮件哈希值。由于您已经知道用户电子邮件地址,因此您可以计算所有用户电子邮件的哈希值,并在每次新 Facebook Connect 用户注册时在您的用户群中搜索匹配项。
You should be asking for permanent access through fb connect authentication. Once you've done that, you'll get a token which gives your permission to access someone's Facebook information, and that token will not expire unless the user explicitly removes you from the permission list or changes his/her password.
Once you have the token, associate that token with the user / create a new field in your user table to store it.
To associate the user with a Facebook account without the user logging in, you can try to match by email. It's not 100% accurate but it's pretty good. Facebook doesn't give you email addresses in text form but you can get email hashes from FQL. Since you already know user email addresses, you can calculate the hash for all of your user emails and search through your user base for matches every time a new Facebook Connect user signs up.