在依赖Auth0进行Facebook身份验证的应用程序中选择用户ID? [英] Choosing user ID in application that relies on Auth0 for Facebook authentication?

查看:72
本文介绍了在依赖Auth0进行Facebook身份验证的应用程序中选择用户ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Angular和PHP创建TODO列表应用程序.

I'm creating a TODO list application using Angular and PHP.

我使用Auth0允许Facebook身份验证,并且在该过程完成后,用户被重定向到添加TODO页面.但是,我对如何在MySQL数据库中保存该TODO项感到困惑.我应该使用哪个用户ID保存TODO项目?

I use Auth0 to allow Facebook authentication and after the process completes the user is redirected to add TODO page. However, I'm confused on how to save that TODO item in my MySQL database. Which user ID should I use to save the TODO item?

我得到了Facebook用户ID作为回报;可以使用FB用户ID保存它吗?

I'm getting Facebook user ID in return; can I save it using the FB user ID?

推荐答案

您可以,但是,如果您使用Facebook ID作为识别MySQL数据库中用户的内部方法,则会降低应用程序的灵活性,更改.

例如,您将Facebook ID保存在具有支持Facebook ID格式的数据类型的列中.现在想象一下,您还要在两个月内支持Google用户.

For example, you save the Facebook ID in a column with a data type that supports the Facebook ID format. Now imagine, that in two months you also want to support Google users.

Google ID的格式可能不支持您选择的数据类型,因此您需要进行更改.此外,甚至可能出现Google和Facebook标识符在全球范围内不唯一的情况,因此Google可以使用相同的标识符来表示用户A,而在Facebook上它可以用于用户B.

The Google ID may be in a format that your chosen data type does not support, so you'll need to make changes. Additionally, it could even the case that Google and Facebook identifiers are not globally unique so the same identifier can be used by Google to represent user A while at Facebook it's used for user B.

您最好的选择是将数据与您管理的内部标识符关联起来保存,然后他们将其映射为一种全球唯一的方式来标识您的用户;例如电子邮件地址.

Your best bet is to save the data in association with an internal identifier that you manage and them mapped it to a globally unique way to identify your users; for example an email address.

鉴于您使用的是Auth0,您可以利用它为您提供

Given you are using Auth0 you can take advantage of the fact that it will provide you with a globally unique identifier for each user. This means you can later support new ways to authenticate your users and Auth0 will always provide your application with a globally unique ID, even in scenarios that users authenticate without having to provide email addresses.

这篇关于在依赖Auth0进行Facebook身份验证的应用程序中选择用户ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆