在Angular Fire Auth之后没有得到回复

时间:2016-06-23 19:00:28

标签: javascript angularjs firebase angularfire firebase-authentication

在使用angularfire注册用户后,我没有收到回复。用户电子邮件显示在Angular的身份验证基础上,但登录的行为空,似乎不执行console.log函数。

这是我的代码,希望你能帮助我。感谢。

    app.controller('UserRegisterCtrl', ["$scope", "$http", "$firebaseAuth", 
    function($scope, $http, $firebaseAuth){

        $scope.createUser = function(user_data) {
            var Auth = $firebaseAuth();
            Auth.$createUserWithEmailAndPassword(user_data.email, user_data.password)
            .then(function(firebaseUser){
                //This part of the code does not execute
                console.log(firebaseUser);
                console.log("User " + firebaseUser.uid + " created successfully!");

            }).catch(function(error) {
                console.error("Error: ", error);
            });
    };
}]);

我正在使用这些库

    <script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>

    <script src="https://cdn.firebase.com/libs/angularfire/2.0.0/angularfire.min.js"></script>

我正在使用新的控制台。感谢

在Google Chrome控制台中,我为signupNewUser请求获取了这些内容:

{
 "kind": "identitytoolkit#SignupNewUserResponse",
 "idToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImZkYTFhMDhjNTAxMTM1MjRhZWQxNmJlZjQ5MzBhODI5NDQ3MmI3OTMifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vYXV0by1mbGVldCIsImF1ZCI6ImF1dG8tZmxlZXQiLCJhdXRoX3RpbWUiOjE0NjY3MTY2MjUsInVzZXJfaWQiOiJRMkNKSDBaTDVvUlBqM05MelNCNW5Qek85SnMxIiwic3ViIjoiUTJDSkgwWkw1b1JQajNOTHpTQjVuUHpPOUpzMSIsImlhdCI6MTQ2NjcxNjYyNSwiZXhwIjoxNDY2NzIwMjI1LCJlbWFpbCI6ImF4YUBjb3JyZW8uY29tIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7InBhc3N3b3JkIjpbImF4YUBjb3JyZW8uY29tIl0sImVtYWlsIjpbImF4YUBjb3JyZW8uY29tIl19fX0.nQphfgsRlvsxEBT9AJzH9aicRAidePomQrRvXZ7lbYI0-VyuNaU2L8Nq_wH4bu-iDLkcUG-fZIy4MgGqKgIIqczqgWq0FTWnVYqTXQykSdIdcwv77g019OiL5ek82hu7pSSNOCJ-aBj1sxfRdP6OjnrGIzrxEkQ0iID2_gbcN7yb-PkRxoes9kOdX200pcO2bEb3kLbA_HyLN9lZ1RFRnjSdi2w16P3yFAiVbr75esJ3Jb0VbaWddqACXabtVXFhAUYkqOpiswJZ98EKhJG3u3zVIoGGi_SJUFrvsPGgJHH9hm4yO2ejjSmDdYwkVQb3pag356m5hZOkhwdmHwQECg",
 "email": "axa@correo.com",
 "refreshToken": "ANflqpHqSZWPVsAE82DTF632-oVCnyGRZk2tSNKwbPOPhgudIHSsfAZa2UxkLkQwpxgWO0APmd7ZPE1hdDU2YoKADb8_0otjVRUnJPceWmj74Mwargx8sboevfloh4bmxPigxBauRuduHvOgs74vUScFCW83tUH1rWc4NXp0ppNYrMN37sqjK-PGQjlVUzONd06I-ypJqYXh",
 "expiresIn": "3600",
 "localId": "Q2CJH0ZL5oRPj3NLzSB5nPzO9Js1"
}

这些用于getAccountInfo请求

{
 "kind": "identitytoolkit#GetAccountInfoResponse",
 "users": [
  {
   "localId": "Q2CJH0ZL5oRPj3NLzSB5nPzO9Js1",
   "email": "axa@correo.com",
   "emailVerified": false,
   "providerUserInfo": [
    {
     "providerId": "password",
     "federatedId": "axa@correo.com",
     "email": "axa@correo.com",
     "rawId": "axa@correo.com"
    }
   ],
   "passwordHash": "UkVEQUNURUQ=",
   "passwordUpdatedAt": 1.466716625E12,
   "validSince": "1466716625",
   "createdAt": "1466716625000"
  }
 ]
}

1 个答案:

答案 0 :(得分:0)

我使用angularfire 2.0.0firebase 3.0.0测试了您的代码,问题肯定依赖于angularfire 2.0.0 。通过将其更新到版本2.0.1,我能够按预期执行代码。

因此,请确保将脚本链接替换为最新的firebase和angularfire版本

<script src="https://www.gstatic.com/firebasejs/3.0.5/firebase.js"></script>

<script src="https://cdn.firebase.com/libs/angularfire/2.0.1/angularfire.min.js"></script>

工作jsFiddle进行演示。