【发布时间】:2019-12-14 22:51:42
【问题描述】:
我正在尝试将我的 firebase 设置配置为可以从我的开发或生产环境发送 verifyEmail 电子邮件。
我有一个 .env 文件,其中有两个设置,如下所示:
REACT_APP_PROD_CONFIRMATION_EMAIL_REDIRECT=https://example.com
REACT_APP_DEV_CONFIRMATION_EMAIL_REDIRECT=http://localhost:3000
然后在我的 firebase 配置文件中:
doSendEmailVerification = () =>
this.auth.currentUser.sendEmailVerification({
url: process.env.NODE_ENV === 'production' ? process.env.REACT_APP_PROD_CONFIRMATION_EMAIL_REDIRECT : process.env.REACT_APP_DEV_CONFIRMATION_EMAIL_REDIRECT,
});
当我在开发环境中进行测试时,这很好用。
当我部署该版本并尝试在生产中对其进行测试时 - 电子邮件不会发送。
两个 firebase 帐户的配置方式相同,以发送电子邮件。
没有生成错误消息,我的提交处理程序中的步骤被跳过了。
我的提交处理程序有:
this.props.firebase
.doCreateUserWithEmailAndPassword(values.email, values.password)
.then(authUser => {
return this.props.firebase.user(authUser.user.uid).set(
{
name: values.name,
email: values.email,
createdAt: new Date()
},
{ merge: true },
);
})
.then(() => {
return this.props.firebase.doSendEmailVerification();
})
.then(() => {
this.setState({ ...initialValues });
this.props.history.push(ROUTES.DASHBOARD);
【问题讨论】:
标签: javascript firebase google-cloud-firestore firebase-authentication