Angular Fire Auth 后没有得到响应 [英] Not getting response after Angular Fire Auth

查看:19
本文介绍了Angular Fire Auth 后没有得到响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向 angularfire 注册用户后,我没有收到回复.用户电子邮件出现在 Angular 的身份验证基础上,但登录行是空的,似乎没有执行 console.log 功能.

I'm not getting response after register a user with angularfire. The user email appears on Angular's Authentication Base, but signed-in row is empty and seems not to execute the console.log function.

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

Here's my code, hope you can help me. Thanks.

    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>

我正在使用新的控制台.谢谢

And I'm using the new console. Thanks

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

In the Google Chrome Console I get these for the signupNewUser request:

{
 "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 请求

And these for the getAccountInfo request

{
 "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"
  }
 ]
}

推荐答案

我已经使用 angularfire 2.0.0firebase 3.0.0 以及 问题肯定依赖于angularfire 2.0.0.通过将其更新到 2.0.1 版,我能够按预期执行代码.

I have tested your code using angularfire 2.0.0 and firebase 3.0.0 and the problem surely relies on angularfire 2.0.0. By updating it to version 2.0.1 I was able to execute the code as expected.

因此,请确保将脚本链接替换为最新的 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 进行演示.

Working jsFiddle for demonstrating.

这篇关于Angular Fire Auth 后没有得到响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆