Firebase - 自定义重置密码登陆页面

Firebase - Customize reset password landing page

我可以在 Firebase 中自定义密码重置的着陆页吗?我想本地化该页面,因为我的应用程序不是英文的。有什么办法吗?

提前致谢。

您可以在 Firebase Console -> Auth -> Email Templates -> Password Reset 下自定义密码重置电子邮件,并将电子邮件中的 link 更改为指向您自己的页面。请注意,<code> 占位符将替换为 URL.

中的密码重置代码

然后,在您的自定义页面中,您可以从 URL 中读取密码重置代码并执行

firebase.auth().confirmPasswordReset(code, newPassword)
    .then(function() {
      // Success
    })
    .catch(function() {
      // Invalid code
    })

您可以选择在显示密码重置表单之前先检查代码是否有效

firebase.auth().verifyPasswordResetCode(code)
    .then(function(email) {
      // Display a "new password" form with the user's email address
    })
    .catch(function() {
      // Invalid code
    })

https://firebase.google.com/docs/reference/js/firebase.auth.Auth#confirmPasswordReset https://firebase.google.com/docs/reference/js/firebase.auth.Auth#verifyPasswordResetCode

@Channing Huang 提供的答案是正确答案,但您还需要记住,它 return 的错误并不总是 invalid-code.

正在检查错误是否可能已过期,用户直到稍后才打开 URL 或其他可能的情况。如果过期,您可以再发送一封电子邮件。