'Firebase: return caught error from signInWithEmailAndPassword
I am using firebase with Email+Password auth provider. Correct credentials case works as expected. My problem is that if credentials are wrong, error is caught, but I don't know how to pass this information back.
I am connecting dispatch from redux store with mapDispatchToProps.
const mapDispatchToProps = (dispatch) => ({
startLogin: (email, password) => dispatch(startLogin(email, password))
});
Then I just call this action with credentials from my component and if undefined was returned (error thrown), I set errors.
startLogin(email, password).then((data) => {
if (!data) {
setErrors({ login: 'Wrong credentials' });
}
});
My action look like this.
export const startLogin = (email, password) => {
return firebase.auth().signInWithEmailAndPassword(email, password).catch((err) => {
console.log(err);
});
};
This works, but console shows POST 400 error which I would like to avoid.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

