简体   繁体   English

我如何更改 Firebase 中的错误消息? 例如,当输入无效密码时?

[英]How can i change the error message in Firebase? For example, when invalid password is entered?

错误信息

How can i change the error message?我怎样才能更改错误消息? I would like to find a way to customise this error message我想找到一种方法来自定义此错误消息

This is my sign in method这是我的登录方法

signInWithEmailAndPassword(auth, email, password)
  .then((res) => {
    dispatch({ type: “LOGIN”, payload: res.user });
    setIsPending(false);
  })
  .catch((err) => {
    setError(err.message);
  });

There is no way to change the error message that Firebase returns, but you can check the error code and then show you own message based on that.无法更改Firebase 返回的错误消息,但您可以检查错误代码,然后根据错误代码显示您自己的消息。

signInWithEmailAndPassword(auth, email, password)
  .then((res) => {
    dispatch({ type: “LOGIN”, payload: res.user });
  })
  .catch((err) => {
    if (err.code === "auth/") {
      setError("The password you entered does not match to this user.");
    }
    else {
      setError(err.message);
    }
  })
  .finally(() => {
    setIsPending(false);
  });

See the full list of error codes to learn what you might want to handle.查看错误代码的完整列表以了解您可能想要处理的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我该如何解决我的问题“FirebaseError:Firebase:错误(auth/invalid-api-key)。” - How can I fixed my problem"FirebaseError: Firebase: Error (auth/invalid-api-key)." 当用户更新密码时,如何捕获 Firebase Auth 返回的特定错误? - How do I catch specific error returned by Firebase Auth, when user updates their password? Twilio Studio IVR - 输入无效数字时,是否有办法播放默认错误消息并返回最新的 Gather 小部件? - Twilio Studio IVR - Is there a way to play a default error message and return to the most recent Gather widget when invalid digits are entered? 我怎样才能克服 Firebase: Error (auth/invalid-api-key) - How can I overcome Firebase: Error (auth/invalid-api-key) unity Firebase 认证-无效密码 - Unity Firebase Authentication - invalid password 用Firebase改密码为Android - Change password with Firebase for Android 我如何在收到背景 firebase 消息时启动 Flutter 应用程序,即使屏幕已锁定我也希望我的应用程序启动 - How i can make Flutter application start when it receives background firebase message even if the screen is locked i want my app to start 我如何更改 firebase 上快照中的数据 - how can i change the data inside the snapshot on firebase 如何更改 xcode 项目的 firebase 数据库? - How can I change xcode project's firebase database? Firebase 使用email登录后google登录报错:密码无效或用户没有密码 - Firebase Sign-in with email after google sign-in has error : The password is invalid or the user does not have a password
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM