我正在使用Angular和Firebase的Email& amp ;;在我的网站上构建用户身份验证。密码认证框架。这不是使用Firebase简单登录框架,而是使用新引入的本机框架。
我的代码使用以下链接指向Firebase:
<script src="https://cdn.firebase.com/js/client/1.1.0/firebase.js"></script>
我可以创建用户,登录等,但ResetPassword调用失败,并出现以下错误。
Error: Firebase.resetPassword failed: First argument must be a valid object.
at Error (native)
at E (https://cdn.firebase.com/js/client/1.1.0/firebase.js:15:73)
at F.G.td (https://cdn.firebase.com/js/client/1.1.0/firebase.js:192:79)
at Object.resetPassword (http://localhost:8000/src/js/services/loginservice.js:78:27)
at k.$scope.resetPassword (http://localhost:8000/src/js/controllers.js:35:20)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:177:68
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:171:237
at f (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:194:174)
at k.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:112:68)
at k.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:112:346)
我使用的代码来自firebase示例,如下所示:
ref.resetPassword(email, function(error) {
if (error === null) {
console.log("Password reset email sent successfully");
} else {
console.log("Error sending password reset email:", error);
}
});
我已经确认传入了有效的电子邮件ID。
你能告诉我这是什么问题吗?
提前致谢 VM
答案 0 :(得分:4)
根据firebase文档,您应该传入一个不是字符串的对象。
https://www.firebase.com/docs/web/api/firebase/resetPassword.html
var credentials = {email: email};
ref.resetPassword(credentials, function(error) {
if (error === null) {
console.log("Password reset email sent successfully");
} else {
console.log("Error sending password reset email:", error);
}
}
答案 1 :(得分:0)
我发现使用一个对象不再有效,它会继续给我&#34;第一个参数必须包含密钥&#34; email&#34;,即使这样,对象也就是上面的答案。 经过很多挫折后,我按照firebase文档传递了email参数。
$scope.resetPassword = function(email){
console.log("made in to auth method for reset passowrd with email - " + email);
ref.resetPassword({
email: email
}, function(error) {
if (error) {
switch (error.code) {
case "INVALID_USER":
console.log("The specified user account does not exist.");
break;
default:
console.log("Error resetting password:", error);
}
} else {
console.log("Password reset email sent successfully!");
}
});
}