如何在firebase中将电子邮件验证码发送到用户电子邮件 [英] How to send email verification code to user email in firebase

查看:47
本文介绍了如何在firebase中将电子邮件验证码发送到用户电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Firebase 身份验证将电子邮件验证码发送到用户的电子邮件.我正在使用 (sendEmailVerification) 方法,但 firebase 会向用户的电子邮件发送验证链接.如果可以,是否可以将验证码发送到用户的电子邮件中,那么如何实现?

I want to send email verification code to user's email using firebase authentication. I am using (sendEmailVerification) method but firebase sends a verification link to user's email. Is it possible to send verification code to user's email if yes then how it can be done?

我正在使用 Angular 4 和 firebase angularfire2

I am using Angular 4 and for firebase angularfire2

谢谢.

推荐答案

如果不想使用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);
  });

这篇关于如何在firebase中将电子邮件验证码发送到用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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