禁用身份验证/用户未找到功能

时间:2021-01-31 09:01:53

标签: firebase firebase-authentication

我有一个带有电子邮件和密码登录方法的 React 应用程序(使用 firebase 实现)。在登录表单中,如果您输入了错误的电子邮件,您将按预期收到 auth/user-not-found 错误。

我有哪些选项可以禁用这种行为?在我看来,恶意用户可以查询电子邮件地址并查看该用户是否存在于我的平台上,这似乎存在安全风险。

1 个答案:

答案 0 :(得分:1)

您无法禁用 firebase 响应的内容,但您应该处理客户端中的错误以显示不太具体的响应。

try {
...
} catch (err) {
  if (err.code === 'auth/user-not-found') {
     alert("Invalid email address and/or password")
  } else {
    console.log("Other error handling method")
  }
}