首页 文章

如何将电子邮件验证码发送到firebase中的用户电子邮件

提问于
浏览
1

我想使用firebase身份验证向用户的电子邮件发送电子邮件验证码 . 我正在使用(sendEmailVerification)方法,但firebase会向用户's email. Is it possible to send verification code to user'发送电子邮件验证链接,如果是,那么它是如何完成的?

我正在使用Angular 4和firebase angularfire2

谢谢 .

2 回答

  • 1

    如果不想使用firebase提供的解决方案,则必须自己处理所有进程,然后将用户 emailVerified 数据更新为 true .

    基本的3个步骤是:
    1.使用"whatever code"向用户发送电子邮件
    2.在您的逻辑中,验证用户输入的"code"
    3. use Firebase Admin SDK to update the user(您只能使用Admin SDK更新此用户属性)

    第3步示例,使用NodeJS

    admin.auth().updateUser(uid, {emailVerified:true})
      .then(function(userRecord) {
          console.log("update success", userRecord.toJSON());
      })
      .catch(function(err) {
          console.log("Error updating user", err);
      });
    
  • 0

    Firebase Auth现在支持在电子邮件验证流程中传递状态/继续URL的功能:https://firebase.google.com/docs/auth/web/passing-state-in-email-actions(网络和iOS,Android正在路上) . 与6位SMS码不同,这些码很长 . 因此,复制代码,特别是如果您在其他设备上打开电子邮件是不可行的 .

相关问题