Firebase-如何从onCreate云功能侦听器发送电子邮件验证? [英] Firebase - How to send email verification from onCreate cloud function listener?

查看:53
本文介绍了Firebase-如何从onCreate云功能侦听器发送电子邮件验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个云函数,该函数将在创建用户时侦听,然后向创建的用户发送电子邮件验证.

I'm trying to create a cloud function that will listen for when users are created, and then send an email verification to the user that was created.

我有此代码:

export const verifyEmail = functions.auth.user().onCreate((user) => {

});

我在这里遇到的问题是 user 使我无法访问 sendEmailVerification .访问该功能的唯一方法是通过 currentUser ,但是由于这种情况发生在对 onCreate 的云功能响应中,因此没有当前用户.

The problem I have here is that user gives me no way of accessing sendEmailVerification. The only way of accessing that function is via the currentUser, but since this happens in a cloud function reaction to onCreate there is no current user.

我需要以某种方式获取 firebase.User 实例,而不是 firebase.UserRecord ,因为 onCreate 给了我.

I need to somehow get a firebase.User instance instead of a firebase.UserRecord, as the onCreate gives me.

我该如何解决?

推荐答案

无法从服务器获取客户端用户,也无法通过Admin SDK发送验证电子邮件.

There is no way to get the client-side user from the server, nor is there a way to send verification emails through the Admin SDK.

您要么必须从应用程序本身触发电子邮件,要么发送自己的验证电子邮件.在后一种情况下,您仍然可以通过生成正确的电子邮件验证链接.

You will either have to trigger the email from the app itself, or send your own verification email. In the latter case, you can still use the existing verification service, by generating the correct email verification link.

另请参阅如何发送使用Firebase Cloud功能创建用户后进行电子邮件验证吗?,我实际上会将您的问题标记为重复的问题.

Also see How to send email verification after user creation with Firebase Cloud functions?, which I'll actually mark your question as a duplicate of.

这篇关于Firebase-如何从onCreate云功能侦听器发送电子邮件验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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