ref。$ authWithPassword不是Firebase中的功能 [英] ref.$authWithPassword is not a function in Firebase

查看:121
本文介绍了ref。$ authWithPassword不是Firebase中的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中一个错误跟随其他jeezzz ...这么多使用firebase作为我的应用程序的简单数据源。我刚开始实施 $ firebaseSimpleLogin 时,我发现虽然stackoverflow,它已被弃用,有利于 $ firebaseAuth 。但是,现在我无法更新控制器中的函数,因为它会一次又一次地抛出相同的错误:
$ b TypeError:ref。$ authWithPassword不是函数



我已经将所有的依赖关系添加到我的控制器中,从我的firebase源创建了ref对象,但是仍然不允许我的用户(已经创建)记录我。这里是代码:

$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $控制器模块。 $ b function($ scope,$ firebaseAuth){
var ref = new Firebase(https://< MYUSERAPI> .firebaseio.com);
var auth = $ firebaseAuth(ref);

$ scope.user = {};
$ scope.SignIn = function(e){
e.preventDefault();
var username = $ scope。 user.email;
var password = $ scope.user.password;

// AMENDED - 仍然出错
验证。$ login('password',{
email:username,
password:password
})
.then(function(user ){
//成功回调
console.log('Authentication successful');
},函数(错误){
//失败回调
console.log ('验证失败');
});
}
}]);

它告诉我$ ref autWWithPassword不是函数吗?我缺少一个插件?



我有以下版本的firebase和Angular fire:

 < script src =https://cdn.firebase.com/js/client/2.2.4/firebase.js>< / script> 
< script src =https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js>< / script>

我已经进入此页 https://www.firebase.com /docs/web/guide/login/password.html ,但不能以我的登录名/密码版本角度重新创建他们的选项。



非常感谢,特别是今天。谢谢。


解决方案

我已经修复了回到$ authWithPassword并添加auth就像每个Anid的帖子,它的工作原理。

  $ scope.user = {}; 
$ scope.SignIn = function(e){
e.preventDefault();
var username = $ scope.user.email;
var password = $ scope.user.password;
auth。$ authWithPassword({
email:username,
password:password
})
.then(function(user){
//成功回调
console.log('Authentication successful');
},function(error){
//失败回调
console.log('Authentication failure');
});
}


One of these days where one bug follows the other jeezzz... So much for using firebase as an easy data source for my apps. I was just about to start implementing $firebaseSimpleLogin when it broke and I found out though stackoverflow that it was deprecated in favour of $firebaseAuth. However, now I am unable to update the function in the controller because it throws the same error time and time again:

TypeError: ref.$authWithPassword is not a function

I have added all the dependencies to my controller, created the ref object from my firebase source and the thing still won't allow my user (already created) to log i. Here is the code:

controllersModule.controller('HomeCtrl',  ["$scope", "$firebaseAuth",
  function($scope, $firebaseAuth) {
    var ref = new Firebase("https://<MYUSERAPI>.firebaseio.com");
     var auth = $firebaseAuth(ref);

  $scope.user = {};
  $scope.SignIn = function(e){
     e.preventDefault();
     var username = $scope.user.email;
     var password = $scope.user.password;

//AMENDED - Still Getting an error auth.$login('password', { email: username, password: password }) .then(function(user) { //Success callback console.log('Authentication successful'); }, function(error) { //Failure callback console.log('Authentication failure'); }); } }]);

It tells me the at ref.$authWithPassword is not a function? Am I missing a plugin?

I have the following versions of firebase and Angular fire:

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

I have gone onto this page https://www.firebase.com/docs/web/guide/login/password.html but cannot recreate their options with my login/password version in angular.

Any help with be much appreciated, today especially. Thanks.

解决方案

I Have fixed by going back to $authWithPassword and adding auth just as per Anid's post and it works.

$scope.user = {};
  $scope.SignIn = function(e){
     e.preventDefault();
     var username = $scope.user.email;
     var password = $scope.user.password;
     auth.$authWithPassword ({
                email: username,
                password: password
            })
            .then(function(user) {
                //Success callback
                console.log('Authentication successful');
            }, function(error) {
                //Failure callback
                console.log('Authentication failure');
            });
  }

这篇关于ref。$ authWithPassword不是Firebase中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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