0

所以似乎我无法在创建用户时直接获取 user.uid,或者它没有在文档中实现。我已经尝试了下面的这段代码无济于事,因为 authdata 返回为空。有解决方法吗?

注意:无论您在哪里看到 Authentication,它都是一个工厂,它返回工作代码以创建用户或相应地使用 createUser() 或 $authWithPassword 登录用户。

$scope.register = function (){ 
    Authentication.register($scope.user)
        .then(function(user){

            var ref =  new Firebase (FIREBASE_URL + 'users');
            var firebaseUsers = $firebaseAuth(ref);

            ref.$authWithPassword({
                email: $scope.user.email,
                password: $scope.user.password
            })
            .then(function(authData){

                var userInfo = {

                regUser: authData.uid,
                date: Firebase.ServerValue.TIMESTAMP,
                firstname: $scope.user.firstname,
                lastname: $scope.user.lastname,
                email: $scope.user.email
                }

            firebaseUsers.$set(regUser,userInfo);

            });     

            Authentication.login($scope.user);                                          
        })
        .then(function(user){
            $timeout(function(){
                $location.path('/meetings');
            }, 2000);
        })
        .catch(function(error){
            $scope.message = error.toString();
        });
} //register

我已经看到了这个回复,但似乎不适用于 angularfire

ref.createUser({
 email: '...',
 password: '...'
}, function(err, user) {
 if (!err) {
   console.log('User created with id', user.uid);
  }
});

任何适用于角度版本的示例?

4

0 回答 0