【问题标题】:Firebase: The email address is already in use by another account. (auth/email-already-in-use)Firebase:电子邮件地址已被另一个帐户使用。 (身份验证/电子邮件已在使用中)
【发布时间】:2022-07-28 12:30:03
【问题描述】:

Firebase:该电子邮件地址已被另一个帐户使用。 (身份验证/电子邮件已在使用中)。

这个错误来自 firebase,一切正常,但是,我想在没有 firebase 名称的情况下显示错误,我该怎么做?

【问题讨论】:

  • 欢迎来到 Stack Overflow。通常在您的问题中包含您正在使用的代码,以便我们可以看到您到目前为止所拥有的内容并帮助您继续进行。请阅读:stackoverflow.com/help/how-to-ask
  • 谢谢,下次我会做得更好。

标签: javascript firebase vue.js firebase-authentication


【解决方案1】:
firebase.auth().createUserWithEmailAndPassword(email, password)
  .then((userCredential) => {
    // Signed in 
    var user = userCredential.user;
    // ...
  })
  .catch((error) => {
    if (error.code == "auth/email-already-in-use") {
        alert("The email address is already in use");
    } else if (error.code == "auth/invalid-email") {
        alert("The email address is not valid.");
    } else if (error.code == "auth/operation-not-allowed") {
        alert("Operation not allowed.");
    } else if (error.code == "auth/weak-password") {
        alert("The password is too weak.");
    }
  });

【讨论】:

  • 谢谢你,辛苦了。
【解决方案2】:

使用错误代码捕获您的错误:

if(errorCode == "auth/email-already-in-use"){
    alert("Email already in use")
}

【讨论】:

    【解决方案3】:

    您可以只拆分错误消息,因为错误消息位于第一个空格字符之后。

    error.substring(error.indexOf(' ') + 1);
    

    【讨论】:

      猜你喜欢
      • 2019-05-17
      • 2017-10-03
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 2023-03-18
      • 2016-11-20
      • 2019-07-05
      • 1970-01-01
      相关资源
      最近更新 更多