react-firebase-hooks
react-firebase-hooks copied to clipboard
CreateUserWithEmailAndPassword doesn't return error for existing users
If there is a user with the same email registered, the call will continue and then() method will be called. There is an HTTP error 400 visible in the console log that is not returned as an error (User Exists)
Example code:
const handleSignup = () => {
const newUser: CoreUser = {
email: watch("email"),
password: watch("password"),
};
if (createUserWithEmailAndPassword) {
createUserWithEmailAndPassword(newUser.email, newUser.password)
.then((result) => {
sendEmailVerification()
.then((result) => {
console.log(`Email was sent to ${newUser.email} `);
})
.catch((error) => {
console.error(
`error while sending email: ${error.message}`,
error
);
});
dispatch(userSignUpSuccess());
})
.catch((error) => {
dispatch(userSignUpError(error));
});
}
};
Console log:

Error returned visible in network section:
{
"error": {
"code": 400,
"message": "EMAIL_EXISTS",
"errors": [
{
"message": "EMAIL_EXISTS",
"domain": "global",
"reason": "invalid"
}
]
}
}