自定义Firebase电子邮件验证模板和操作处理程序

发布于 2025-01-18 10:50:47 字数 572 浏览 3 评论 0原文

我想自定义电子邮件模板(使用触发电子邮件扩展模板)将验证链接发送给用户。

我知道,由于防止垃圾邮件,不可能从火箱控制台更改模板。

我知道可以自定义操作电子邮件处理程序的能力(用户在验证电子邮件中点击链接时登录的页面)以及手动更新Auth用户的EmailVerified属性的能力。

是否还有一种生成Firebase将使用的验证链接的方法?具有以下属性的一个:

  • 模式
  • oobcode
  • apikey
  • conluturl
  • lang

我的理想解决方案是在使用生成的验证链接注册后将自定义模板发送给用户。将用户直接进入自定义处理程序页面,并使用applactionCode()函数,如 docs 要验证电子邮件(我希望此隐含地更新emailverified属性属性 auth.user 记录。)

I would like to customize the email template (using the Trigger Email extension templates) to send verification links to users.

I understand it is not possible to change the template from the Firebase console as it prevents spam.

I am aware of the ability to customize action email handlers (The page that the user lands on when the link in verification email is clicked), as well as the ability to update the auth user's emailVerified property manually.

Is there also a way to generate the verification link that firebase would have used? One with the following properties:

  • mode
  • oobCode
  • apiKey
  • continueUrl
  • lang

My ideal solution is to send a custom template to the user upon registration with the generated verification link. Direct users to a custom handler page, and use the applyActionCode() function as shown in The Docs to verify the email (I hope this implicitly updates the emailVerified property on the Auth.User record.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一花一树开 2025-01-25 10:50:47

我通过创建用户并使用管理 SDK 在后端生成链接来实现这一目标。

因此,您的前端将调用可调用函数或定制 API 端点来进行注册,而不是直接使用 SDK。

可调用的内容如下:

  • 在 Auth 中创建用户: auth.createUser( )
  • 在数据库中创建用户(Firestore、Mongo 等)。
  • 如果需要,分配自定义声明:auth.setCustomUserClaims
  • 构建登录链接:auth.generateSignInWithEmailLink()
  • 将电子邮件发送到电子邮件事务 API

您将需要一个 ESP,例如 Sendgrid、MailChimp、MailGun 等来完成最后一步。在那里您将可以自由地构建自己的模板。

请注意,generateSignInWithEmailLink 将负责验证电子邮件地址和登录。因此它可以用于登录和注册。

干杯

I have achieved this by creating the user and generating the link on the backend with the admin SDK.

So your frontend would call a callable function or bespoke API endpoint for instance for the registration instead of using the SDK directly.

The callable would go about this:

  • Creating the user in Auth: auth.createUser()
  • Creating the user in your DB (Firestore, Mongo etc.)
  • Assigning custom claims if required: auth.setCustomUserClaims
  • Building the link for signin: auth.generateSignInWithEmailLink()
  • Sending the email to an email transactional API

You will need an ESP e.g Sendgrid, MailChimp, MailGun etc. for the last step. There you will have all the freedom to build your own templates.

Please note that the generateSignInWithEmailLink will take care of verifying an email address and signing-in. It could therefore be used for login and registration.

Cheers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文