2014-10-18 69 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!"); 
    } 
}); 

}