Firebase: The email address is already in use by another account. (auth/email-already-in-use).
This error is ing from firebase and everything works, but, i would like to diplay error without firebase name there, how can i do that?
Firebase: The email address is already in use by another account. (auth/email-already-in-use).
This error is ing from firebase and everything works, but, i would like to diplay error without firebase name there, how can i do that?
Share Improve this question edited Feb 5, 2022 at 15:04 Doug Stevenson 318k36 gold badges456 silver badges473 bronze badges Recognized by Google Cloud Collective asked Feb 5, 2022 at 8:33 Edin OsmicEdin Osmic 4462 gold badges11 silver badges29 bronze badges 2- 3 Wele to Stack Overflow. It is customary to include in your question the code you are working with so that we can see what you have so far and help you proceed with that. Please read: stackoverflow./help/how-to-ask – Doug Stevenson Commented Feb 5, 2022 at 15:05
- Thank you, i will do better next time. – Edin Osmic Commented Feb 8, 2022 at 11:57
3 Answers
Reset to default 3Capture your error with error code :
if(errorCode == "auth/email-already-in-use"){
alert("Email already in use")
}
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.");
}
});
you can just split your error message because the actual message is after the first space character.
error.substring(error.indexOf(' ') + 1);