2017-03-04 119 views
0

我在我的项目中使用#AngularFire2。我想在我的登录视图中添加一个重置/忘记密码链接。如何添加忘记/重置密码链接在#Firebase

任何想法如何完成?

我想#AskFirebase

+1

请参阅https://firebase.google.com/docs/auth/web/manage-users#sen d_a_password_reset_email。如果您在完成这项工作时遇到问题,请分享[重现您卡住的最小代码](http://stackoverflow.com/help/mcve)。 –

+0

谢谢@FrankvanPuffelen。这是完美的!奇迹般有效。但是我在'AngularFire' auth对象中找不到'auth.sendPasswordResetEmail'这个函数。它是否包含在内?我正在使用'angularfire2:^ 2.0.0-beta.8,' – Dhiman

+1

我不知道它是否包含在内。如果没有,您可以直接在Firebase JavaScript API上调用它。 –

回答

0

只是实现这个两个方法:

做一个请求,火力地堡将发送电子邮件的代码

requestPasswordReset(email: string) : Promise<any> { 
    return this.afAuth.auth.sendPasswordResetEmail(email); 
} 

然后,你需要得到这个代码用户使用新密码

confirmNewPassword(code: string, password: string) : Promise<any> { 
    return this.afAuth.auth.confirmPasswordReset(code, password); 
}