我正在尝试在应用程序的注册过程中纳入电子邮件验证步骤。在线查看文档,似乎是在前端进行操作。
问题是我在网上看到的示例,这些示例在前端完成了整个登录过程,仅包含sendEmailVerification方法。
sendEmailVerification方法
firebase.auth().currentUser.sendEmailVerification().then(function() {
// Email sent.
}).catch(function(error) {
// An error happened.
});
我(相反)在后端建立了我的注册方法,在前端建立了相应的处理程序。
前端注册处理程序
authHandler = () => {
const authData = {
email: this.state.controls.email.value,
password: this.state.controls.password.value
};
this.props.onTryAuth(authData, this.state.authMode);
// ontTryAuth is a backend action that creates new users in Firebase
};
在此前端处理程序代码中包含sendEmailVerification方法是一个好主意吗?如果是这样,我该怎么做?
答案 0 :(得分:0)
是的,您可以使用它。首先,这种方法是由Firebase构建的,因为使用Firebase的人并不总是/从来没有服务器。您可以在服务器中构建自己的注册方法,但是如果您开始覆盖Firebase提供的所有功能,为什么还要使用Firebase?对我来说,我将Firebase视为原型工具,因此我使用了它们提供的所有功能,因此让我可以更快地运行应用程序。
让我知道这是否有意义。