Firebase 已注册用户 - 将用户存储在节点中,而不是存储在注册用户中

Firebase signed up users - Storing users in node vs in registered users

本文关键字:用户 存储 注册 节点 Firebase      更新时间:2023-09-26
如何将

用户存储在节点中,而不仅仅是存储在注册用户中,这就是当前代码正在做的事情(在Firebase中) 这是我的代码登录控制器 谢谢:

app.controller('LoginCtrl', function($scope, $state) {

$scope.data = {};

$scope.signupEmail = function(){

var ref = new Firebase("https://FIREBASE-APP>.firebaseio.com");
ref.createUser({
  email    : $scope.data.email,
  password : $scope.data.password
}, function(error, userData) {
  if (error) {
    console.log("Error creating user:", error);
  } else {
    console.log("Successfully created user account with uid:", userData.uid);
  }
});

};

相关的用户数据存储在userData对象中。要保存它,您可以执行以下操作:

ref.createUser({
    email    : $scope.data.email,
    password : $scope.data.password
}, function(error, userData) {
    if (error) {
    console.log("Error creating user:", error);
    } else {
        console.log("Successfully created user account with uid:", userData.uid);
        ref.child('users').push(userData); 
    //   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  }
});