2014-10-18 72 views
2

我正在使用Angular和Firebase的电子邮件在我的网站中构建用户身份验证&密码身份验证框架。这不是使用Firebase简单登录框架,而是新引入的本机框架。Firebase ResetPassword问题

我的代码链接到火力使用:

<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) 

我使用的代码是从火力举例如下:

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

回答

4

按照火力文档,你应该传递的对象不是字符串。

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); 
    } 
} 
+0

API文档和他们的“引导”是不同的。感谢您指出了这一点。 – 2014-10-29 18:33:53

+0

请直接与他们联系,让他们知道的迪screpancy。你会为他们做一个忙,任何其他可能会陷入困境的人。 – 2014-10-29 18:37:04

0

我发现,使用对象不再起作用,它会不断给我“的第一个参数必须包含的关键‘电子邮件’,即使在那时,目标是为上述问题的答案。 太多的无奈之后,我得到它的工作通过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!"); 
    } 
}); 

}