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

查看:267
本文介绍了如何在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数据更新为.

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更新此用户属性)

The basic 3 steps are:
1. send an email to the user with "whatever code" you want
2. in your logic, validate the "code" typed by the user
3. use Firebase Admin SDK to update the user (you can only update this user property using the 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天全站免登陆