成功更改密码后,Firebase 重定向到网页

lak*_*hmi 4 html javascript web-applications firebase firebase-authentication

我在带有 Ionic 的网络应用程序中使用 firebase,并且我想在用户成功更改密码后将用户重定向到特定页面(在我的情况下为登录页面)。目前,当用户点击密码重置链接时,他被重定向到另一个浏览器页面,显示他已成功更改密码。

在此处输入图片说明

更改密码后,我想将他重定向到我的网络应用程序的页面。有可能这样做吗?

boj*_*eil 8

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

var actionCodeSettings = {
  // After password reset, the user will be give the ability to go back
  // to this page.
  url: 'https://www.example.com/afterPasswordReset',
  handleCodeInApp: false
};
firebase.auth().sendPasswordResetEmail(email, actionCodeSettings)
  .then(function() {
    // Password reset email sent.
  })
  .catch(function(error) {
    // Error occurred. Inspect error.code.
  });
Run Code Online (Sandbox Code Playgroud)

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

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