Reputation: 446
Firebase: The email address is already in use by another account. (auth/email-already-in-use).
This error is coming from firebase and everything works, but, i would like to diplay error without firebase name there, how can i do that?
Upvotes: 0
Views: 10774
Reputation: 1
you can just split your error message because the actual message is after the first space character.
error.substring(error.indexOf(' ') + 1);
Upvotes: 0
Reputation: 104
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.");
}
});
Upvotes: 3
Reputation: 6919
Capture your error with error code :
if(errorCode == "auth/email-already-in-use"){
alert("Email already in use")
}
Upvotes: 3