未发送Firebase确认电子邮件 [英] Firebase confirmation email not being sent

查看:120
本文介绍了未发送Firebase确认电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功设置Firebase电子邮件/密码身份验证,但出于安全原因,我希望用户确认她/他的电子邮件。
在Firebases网站上说:

I've set up Firebase email/password authentication successfully, but for security reasons I want the user to confirm her/his email. It says on Firebases website:


当用户使用电子邮件地址和密码注册时,会发送一封确认电子邮件给验证他们的电子邮件地址。

When a user signs up using an email address and password, a confirmation email is sent to verify their email address.

但是当我注册时,我没有收到确认邮件。

But when I sign up, I doesn't receive a confirmation email.

我看了,只能找到发送密码重置电子邮件的代码,而不是发送电子邮件确认的代码。

I've looked and can only find a code for sending the password reset email, but not a code for sending the email confirmation.

我在这里看过:

https://firebase.google.com/docs/auth/ios/manage-users#send_a_password_reset_email

任何人都知道如何我可以做到这一点吗?

anyone got a clue about how I can do it?

推荐答案

我注意到新的Firebase电子邮件身份验证文档没有正确记录。

I noticed that the new Firebase email authentication docs is not properly documented.

firebase.auth().onAuthStateChanged(function(user) {
  user.sendEmailVerification(); 
});

请注意:

Do note that:


  1. 您只能向使用电子邮件和密码方法创建的用户对象发送电子邮件验证 createUserWithEmailAndPassword

  2. 只有在您将用户签署为已验证状态后, Firebase将返回auth对象的承诺。
  3. 旧的onAuth方法已更改为 onAuthStateChanged

  1. You can only send email verification to users object whom you created using Email&Password method createUserWithEmailAndPassword
  2. Only after you signed users into authenticated state, Firebase will return a promise of the auth object.
  3. The old onAuth method has been changed to onAuthStateChanged.

检查电子邮件是否被验证:

To check if email is verified:

firebase.auth().onAuthStateChanged(function(user) { 
  if (user.emailVerified) {
    console.log('Email is verified');
  }
  else {
    console.log('Email is not verified');
  }
});

这篇关于未发送Firebase确认电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆