首页 > 解决方案 > 如果成功验证,如何修改 Firebase 身份验证响应以包含指向应用程序的链接?

问题描述

我想包含一个指向该应用程序的链接,以便用户在他们的电子邮件得到确认后能够直接登录。firebase 控制台没有显示可以编辑的位置。

firebase 控制台没有显示可以编辑的位置。

伪代码:

您的电子邮件已得到确认。现在请继续登录:添加到应用程序的链接。

标签: firebasefirebase-authentication

解决方案


您必须传递一个继续 URLActionCodeSettings以将用户重定向回应用程序:

var actionCodeSettings = {
  // After email is verified, the user will be give the ability to go back
  // to the sign-in page.
  url: 'https://www.example.com/login',
  handleCodeInApp: false
};
firebase.auth().currentUser.sendemailverification(actionCodeSettings)
  .then(function() {
    // Verification email sent.
  })
  .catch(function(error) {
    // Error occurred. Inspect error.code.
  });

了解更多关于ActionCodeSettings重定向和传递状态的信息: https ://firebase.google.com/docs/auth/web/passing-state-in-email-actions

您还可以在此处构建自己的自定义登录页面: https ://firebase.google.com/docs/auth/custom-email-handler


推荐阅读