firebase - 在 Firebase 用户表上添加额外详细信息

标签 firebase angularfire firebasesimplelogin firebase-authentication

我正在开发一个 firebase+angularjs 应用程序,我使用简单的电子邮件和密码身份验证,并且它工作正常。

我只是想知道是否可以在 firebase email+password auth 使用的用户表上添加额外的用户数据,就像我想添加账单信息和有关用户的其他详细信息,而无需在上创建额外的节点/表firebase 来存储这些额外的数据。

最佳答案

Firebase 将电子邮件/密码用户存储在您无权直接访问的单独位置。您无法在此位置扩展数据。

由于许多应用程序开发人员希望访问其应用程序代码中的用户数据,因此通常的做法是将所有用户存储在应用程序数据库本身内的 /users 节点下。缺点是你必须自己做这件事。但这样做的好处是,如果您愿意,您可以存储任何额外的信息。

请参阅Firebase guide on storing user data示例代码。从那里:

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.onAuth(function(authData) {
  if (authData && isNewUser) {
    // save the user's profile into Firebase so we can list users,
    // use them in Security and Firebase Rules, and show profiles
    ref.child("users").child(authData.uid).set({
      provider: authData.provider,
      name: getName(authData)
    });
  }
});

关于firebase - 在 Firebase 用户表上添加额外详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31038611/

相关文章:

angularjs - 如何让 Controller 等待服务返回值以及如何访问 Controller 中的返回值?

java - Firebase 身份验证限制

ios - 如何检索存储在 firebase 中的图像以在 View ImageView 中显示它

swift - Firebase 删除值无法正常工作

arrays - 元素未从 FireBase 附加到数组

java - 用户登录后 Firebase 检索信息

javascript - 如何在 Angular 和 Firebase 中使用 Gmail 进行电子邮件身份验证?

javascript - 使用 firebase 的即时模式自动登录

javascript - 如何在 Angular UI typeahead 中正确使用 select 和 firebase 数据

ios - 无法使用带有电子邮件/密码的 Firebase 简单登录来执行完成 block