简体   繁体   English

链接通过Facebook登录的新用户连接到现有帐户

[英]Linking new users signed in via Facebook connect to existing accounts

I have recently implemented login to my via facebook connect. 我最近实现了登录我的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). 注册帐户的旧方式和新方式(Facebook连接)。

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. 我想做的一件事是将新的facebook连接用户帐户链接到现有帐户(如果他们以旧方式登录)。

Has anyone had any success doing this? 有没有人有这样的成功?

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. 您需要记住的是,只要帐户被授权通过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. 您应该做的是在数据库中维护第二个链接帐户表,以便您知道谁是谁以及他们是否与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 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: 即:

Sign Up should fail if the user denies permission to the app (category: sign up) 如果用户拒绝对应用程序的许可,则注册失败(类别:注册)

Since we need access to an email address, Sign Up should fail if the user provides publish permission but denies email permission (category: sign up) 由于我们需要访问电子邮件地址,因此如果用户提供发布权限但拒绝电子邮件权限,则注册将失败(类别:注册)

If the user provides an email address that already exists in your system, fail Sign Up. 如果用户提供了系统中已存在的电子邮件地址,则无法注册。 Make sure no YouFace backend tables are modified (category: sign up, 1:1 mapping) PS - when this happens, I didn't find a way for you to de-authorize YouFace on the Facebook user's behalf. 确保没有修改YouFace后端表(类别:注册,1:1映射)PS - 当发生这种情况时,我没有找到一种方法让您代表Facebook用户取消授权YouFace。 The user must manually do this if they wish you use the same account but provide a different email address. 如果用户希望您使用相同的帐户但提供不同的电子邮件地址,则必须手动执行此操作。

Accounts created using Facebook Connect should not be able to login using YouFace's default email/password login system (category: sign in, account security). 使用Facebook Connect创建的帐户不能使用YouFace的默认电子邮件/密码登录系统登录(类别:登录,帐户安全)。 PS: Since YouFace accounts require a password and those created using Facebook Connect don't, make sure to insert a random password hash into your table to avoid silly errors PS:由于YouFace帐户需要密码而使用Facebook Connect创建的密码不需要,因此请确保在表中插入随机密码哈希以避免愚蠢的错误

Accounts created using YouFace should be able to sign in without requiring to be signed into Facebook, even if when a link to a Facebook accounts exists (category: sign in) 使用YouFace创建的帐户应该能够登录而无需登录Facebook,即使存在指向Facebook帐户的链接时(类别:登录)

Any many more 还有更多

You should be asking for permanent access through fb connect authentication. 您应该通过fb connect身份验证请求永久访问。 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. 完成后,您将获得一个令牌,该令牌允许您访问某人的Facebook信息,除非用户明确将您从权限列表中删除或更改了他/她的密码,否则该令牌不会过期。

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. 要在没有用户登录的情况下将用户与Facebook帐户相关联,您可以尝试通过电子邮件进行匹配。 It's not 100% accurate but it's pretty good. 这不是100%准确,但它非常好。 Facebook doesn't give you email addresses in text form but you can get email hashes from FQL. Facebook不会以文本形式提供电子邮件地址,但您可以从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. 由于您已经知道用户电子邮件地址,因此您可以计算所有用户电子邮件的哈希值,并在每次新的Facebook Connect用户注册时在您的用户群中搜索匹配项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM