简体   繁体   English

如何自定义 firebase 动作 URL 进行密码重置和 email 验证?

[英]How to customize firebase action URL for password reset and email verification?

I'm new to firebase and I Want to know how to customize action URL for the password reset and email verification mail.我是 firebase 的新手,我想知道如何为密码重置和 email 验证邮件自定义操作 URL。

For Example https://app.firebaseapp.com/__/auth/action // here I Don't want firebaseApp.com.例如https://app.firebaseapp.com/__/auth/action // 这里我不想要 firebaseApp.com。 So how to do I Customize this action URL from firebase.?那么如何从 firebase 自定义这个动作 URL 呢? Please help me as I am new to firebase.请帮助我,因为我是 firebase 的新手。 any help would be appreciated任何帮助,将不胜感激

if you want to change or customize default action firebase URL: https://app.firebaseapp.com to https://your_domain.com .如果您想更改或自定义默认操作 firebase URL: https://app.firebaseapp.comhttps://your_domain.com

You just need to create a Firebase Dynamic link of your custom domain or part of your website and you're done.您只需要创建自定义域或网站部分的 Firebase 动态链接即可。 After Creating Firebase Dynamic Link, go to Authentication/Templates on Firebase, and click on Customize URL of your action link and type your Dynamic Link and hit done.创建 Firebase 动态链接后,转到 Firebase 上的身份验证/模板,然后点击自定义您的操作链接的 URL 并输入您的动态链接并点击完成。 Your Default Action URL link has been changed.您的默认操作 URL 链接已更改。

More information please visit https://firebase.google.com .更多信息请访问https://firebase.google.com

I know it's an year old question now, but this is the correct answer.我知道这是一个一年前的问题,但这是正确的答案。 Custom Email Handler Docs . 自定义电子邮件处理程序文档 Simply customizing that URL wont help as it's just half of the work.简单地自定义该 URL 无济于事,因为它只是工作的一半。

您可以参考 Firebase 支持文章https://support.google.com/firebase/answer/7000714?hl=en 中的“自定义发件人域”部分

I believe i've found a way to accomplish this without the need to create your own webpage.我相信我已经找到了一种无需创建自己的网页即可完成此任务的方法。

First go to your Firebase Console and then Firebase Hosting.首先转到您的 Firebase 控制台,然后转到 Firebase 托管。 Create a unique subdomain like verify.yourdomain.com or app.yourdomain.com .创建一个唯一的子域,如verify.yourdomain.comapp.yourdomain.com Redirect that domain to your project's default domain.将该域重定向到您项目的默认域。

verify.yourdomain.com redirects to default-1234.firebaseapp.com . verify.yourdomain.com重定向到default-1234.firebaseapp.com

Once Firebase verifies your subdomain after some time, it should be labeled as connected. Firebase 在一段时间后验证您的子域后,应将其标记为已连接。 Then within the console go to Authentication and then Templates.然后在控制台中转到身份验证,然后转到模板。 Replace the default domain within the action handler to your new subdomain.将操作处理程序中的默认域替换为您的新子域。

https://verify.yourdomain.com/__/auth/action . https://verify.yourdomain.com/__/auth/action

That should be it.应该是这样。

This is an issue I've had to scramble the internet to fix a good number of times now.这是我现在不得不在互联网上多次修复的问题。 This is unfortunately the case because there's no specific Firebase documentation for it.不幸的是,情况确实如此,因为没有针对它的特定 Firebase 文档。

Here are the steps to follow:以下是要遵循的步骤:

  1. Login to the firebase console, then go to the dashboard of the firebase project in question.登录到 firebase 控制台,然后转到相关 firebase 项目的仪表板。
  2. Click the "Hosting" nav on the sidebar单击侧边栏上的“托管”导航
  3. Click the "Get Started" button on the hosting page.单击托管页面上的“开始使用”按钮。
  4. A set up wizard will show up, but keep clicking "Next" without paying any mind to the instructions on the wizard将显示设置向导,但请继续单击“下一步”,而无需注意向导上的说明
  5. When you're done clicking through, the actual "Hosting" page will show-up.单击完成后,将显示实际的“托管”页面。 Click the "Add custom domain" button.单击“添加自定义域”按钮。
  6. Follow through with the pop-up to add and verify your custom domain name.按照弹出窗口添加和验证您的自定义域名。
  7. Once that is done, click the "Authentication" nav on the sidebar完成后,单击侧边栏上的“身份验证”导航
  8. Click the "Templates" tab on the Authentication page.单击身份验证页面上的“模板”选项卡。
  9. Now you can edit each email template by clicking the pencil button and then scroll down to click the "customise action url" button.现在,您可以通过单击铅笔按钮来编辑每个电子邮件模板,然后向下滚动以单击“自定义操作 url”按钮。
  10. Replace the domain name of the action URL with your custom domain (which you verified on step 6) and save it.将操作 URL 的域名替换为您的自定义域(您已在步骤 6 中验证)并保存。 Note, you are only replacing the domain name of the action URL.请注意,您只是替换了操作 URL 的域名。 The path of the action URL should remain the same.操作 URL 的路径应保持不变。

That's it you can now test that it's working by sending a "password reset" email or "account verification" email to yourself.就是这样,您现在可以通过向自己发送“密码重置”电子邮件或“帐户验证”电子邮件来测试它是否正常工作。

For a more detailed guide on the steps to follow, you can read this article that I wrote about it https://ifedapo.com/posts/customise-firebase-action-url .有关要遵循的步骤的更详细指南,您可以阅读我写的这篇文章https://ifedapo.com/posts/customise-firebase-action-url

It contains screenshots and more elaborate steps to follow so you might rather find it more helpful if the steps above seem too crammed up for you.它包含屏幕截图和更详细的步骤,因此如果上述步骤对您来说过于拥挤,您可能会发现它更有帮助。

如果您使用支持合成记录(例如 Google Domains)的 DNS 注册商,您只需使用支持 SSL 和路径转发的合成记录即可完成此操作。

I don't know if there is any drawbacks with this (it's working for me), but the simplest way, if you are already using a custom domain in your app, is to just change the domain in the custom URL in the email template.我不知道这是否有任何缺点(它对我有用),但最简单的方法是,如果您已经在应用程序中使用自定义域,则只需更改电子邮件模板中自定义 URL 中的域.

For example, just change https://myapp.firebaseapp.com/__/auth/action to https://myapp.com/__/auth/action in the template configuration, considering that you have already configured myapp.com to be your custom domain in firebase hosting.例如,只是改变https://myapp.firebaseapp.com/__/auth/actionhttps://myapp.com/__/auth/action在模板配置,考虑到你已经配置myapp.com是您在 firebase 托管中的自定义域。

No need for dynamic links, redirects or even to create a subdomain in your DNS!无需动态链接、重定向,甚至无需在您的 DNS 中创建子域!

Say, your firebase link is https://myapp.firebaseapp.com/__/auth/action You want it https://auth.mydom.com/__/auth/action说,你的火力基地链接是https://myapp.firebaseapp.com/__/auth/action你想要它https://auth.mydom.com/__/auth/action

  1. Create a CNAME in your domain(mydom.com) with the Name as auth and the Value as myapp.firebaseapp.com在您的域 (mydom.com) 中创建一个 CNAME,名称为auth值为 myapp.firebaseapp.com

  2. Then go to your Firebase Project -> Authentication -> Templates tab on top of the page -> click on pencil button -> customise action url on the bottom -> Replace https://myapp.firebaseapp.com/__/auth/action with https://auth.mydom.com/__/auth/action然后转到您的 Firebase 项目 ->身份验证-> 页面顶部的模板选项卡 -> 单击铅笔按钮 ->自定义底部的操作网址-> 替换https://myapp.firebaseapp.com/__/auth/actionhttps://auth.mydom.com/__/auth/action

That's it.而已。

As of August 2022, the solution for this is to load the "Authentication" product of Firebase in the console ("Authentication" is under the "Build" product category on the left side or can be found in "All products"):截至 2022 年 8 月,解决方案是在控制台中加载 Firebase 的“Authentication”产品(“Authentication”在左侧“Build”产品类别下或可以在“All products”中找到):

左侧导航中的认证产品

Then select the "Templates" tab in the Authentication screen:然后 select 身份验证屏幕中的“模板”选项卡:

在此处输入图像描述

Select any of the Email templates (like "Password reset") and click on the Pencil icon to edit: Select 任何 Email 模板(如“密码重置”)并单击铅笔图标进行编辑:

在此处输入图像描述

Click on the "Customize domain" link under the disabled domain name field:单击禁用的域名字段下的“自定义域”链接: 在此处输入图像描述

Add your custom domain name (which you already own and have DNS control over) in the dialog box that appears:在出现的对话框中添加您的自定义域名(您已经拥有并拥有 DNS 控制权):

在此处输入图像描述

(If the "Continue" button is disabled after typing in the domain name, make sure you click outside of the text input box. The "Continue" button should then be active.) (如果在输入域名后“继续”按钮被禁用,请确保您在文本输入框之外单击。“继续”按钮应该处于活动状态。)

The next dialog box will provide DNS records that need to be added/updated.下一个对话框将提供需要添加/更新的 DNS 记录。 There should be two TXT records (av=SPF and a firebase record) and two CNAME records (two mail records).应该有两条 TXT 记录(av=SPF 和一条 firebase 记录)和两条 CNAME 记录(两条邮件记录)。 Update those on your DNS and then return to the Firebase Console to click on "Verify".更新 DNS 上的那些,然后返回 Firebase 控制台单击“验证”。 Google may be able to see and verify the new records immediately or it may take some time (they claim up to 48 hours, but if it takes that long, it is possible a mistake was made).谷歌可能能够立即查看并验证新记录,或者可能需要一些时间(他们声称最多需要 48 小时,但如果需要这么长时间,则可能出现错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM