Angularjs $authWithPassword始终返回“;指定的密码不正确。”;
我正在尝试使用angularfire(firebase)实现密码身份验证。 javascript是用coffeescript(!)实现的。 创建用户和所有其他firebase功能似乎都可以正常工作 但是,当尝试使用$authWithPassword登录用户时,无论密码是什么,它都会返回“指定的密码不正确”的错误 实施方式: 在咖啡脚本中:Angularjs $authWithPassword始终返回“;指定的密码不正确。”;,angularjs,coffeescript,firebase,angularfire,firebase-authentication,Angularjs,Coffeescript,Firebase,Angularfire,Firebase Authentication,我正在尝试使用angularfire(firebase)实现密码身份验证。 javascript是用coffeescript(!)实现的。 创建用户和所有其他firebase功能似乎都可以正常工作 但是,当尝试使用$authWithPassword登录用户时,无论密码是什么,它都会返回“指定的密码不正确”的错误 实施方式: 在咖啡脚本中: $scope.loginUser = ()-> console.log("logging in! "+ $scope.loginEmai
$scope.loginUser = ()->
console.log("logging in! "+ $scope.loginEmail + " "+$scope.loginPassword)
$scope.auth.$authWithPassword({"email": $scope.loginEmail, "password": $scope.loginPassword})
.then (authData)->
$scope.authData = authData
console.log(authData)
$mdToast.showSimple("welcome!")
return
.catch (error)->
console.log(error)
$mdToast.showSimple("there was a problem")
return
return
。。它总是返回“有一个问题…控制台说问题是密码”
出了什么问题?(我仔细检查了一下-它不是密码。)
转换为javascript:
$scope.loginUser = function() {
console.log("logging in! " + $scope.loginEmail + " " + $scope.loginPassword);
$scope.auth.$authWithPassword({
"email": $scope.loginEmail,
"password": $scope.loginPassword
}).then(function(authData) {
$scope.authData = authData;
console.log(authData);
$mdToast.showSimple("welcome!");
})["catch"](function(error) {
console.log(error);
$mdToast.showSimple("there was a problem");
});
};
---编辑---
所使用的html标记:
<md-card-content>
<div>
<md-input-container>
<input placeholder="email" type="email" ng-model="loginEmail">
</md-input-container>
<md-input-container>
<input placeholder="password" type="password" ng-model="loginPassword">
</md-input-container>
</div>
<div><span></span>
<md-button ng-click="loginUser()" class="md-primary">
<md-icon>person</md-icon><span style="font-size:16px">connect</span>
</md-button>
</div>
</md-card-content>
个人连接
我想提到的是,即使将用户名和密码硬编码到javascript中,它仍然无法登录。因此,在html部分,这似乎不是一个问题。此外,当我在控制台中收到错误消息时,loginUser()函数确实会激发 很抱歉,我在代码的其他地方发现了这个bug。问题是在创建新用户时,我有一个代码,在密码中添加了一些字符,实际上,我试图登录的密码总是错误的。所以上面的代码现在可以正常工作了。
谢谢 在哪里给“.then”(函数(authData))赋予authData?我的意思是,你从来没有给函数赋予这个值,或者当它试图设置$scope.authData=authData时,我看不到这个值;在这段代码上面的主控制器中,我有…ref=new Firebase(')$scope.auth=$firebaseAuth(ref)$scope.authData=$scope.auth.$getAuth(),但是当你调用.then(function(authData))“您正在重命名$scope.authData=authData;此authData为null,或者当您将其交给函数时?我不理解这个问题。.then”函数是$authWithPassword API的一部分,如angularfire文档中所述。这是否显示了任何内容?console.log(authData);