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

时间:2019-03-22 09:16:30

标签: javascript html firebase web-applications firebase-authentication

我正在Ionic的Web应用程序中使用firebase,我希望在用户成功更改密码后将其重定向到特定页面(在我的情况下为登录页面)。 此刻,当用户单击密码重置链接时,他会在另一个浏览器页面上重定向,该页面显示他已成功更改密码。

enter image description here

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

1 个答案:

答案 0 :(得分:2)

您必须通过ActionCodeSettings传递继续URL才能将用户重定向回应用程序:

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.
  });

进一步了解ActionCodeSettings和重定向状态: https://firebase.google.com/docs/auth/web/passing-state-in-email-actions

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

相关问题