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

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

问题描述

我正在使用 Angular 和 PHP 创建一个待办事项列表应用程序.

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,您可以利用它为您提供每个用户的全局唯一标识符.这意味着您以后可以支持对用户进行身份验证的新方法,并且 Auth0 将始终为您的应用程序提供一个全球唯一的 ID,即使在用户无需提供电子邮件地址即可进行身份验证的情况下也是如此.

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天全站免登陆