且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-12-01 17:46:40

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

If don´t want to use the solution provided by firebase, you have to handle all the process yourself and then update the user emailVerified data to true.

基本的3个步骤是:
1. 用你想要的任何代码"向用户发送电子邮件
2. 在您的逻辑中,验证用户输入的代码"
3. 使用 Firebase Admin SDK 更新用户(您只能使用 Admin SDK 更新此用户属性)

第 3 步示例,使用 NodeJS

Step 3 example, using 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);
  });