So I am trying to authenticate users to firebase and add them to my users collection and store them by their unique id.
When I go to my signup screen, if I reload the simulator the first account I try to sign up will authenticate but not be added to the database, but any subsequent account I add will authenticate and upload to the database. However, once I reload the application it will restart the process of not uploading the first one.
This is the call I am making-
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((user) => {
const dbRoot = firebase.firestore().collection('users');
dbRoot.doc(user.user.uid).set({ email });
dispatch({ type: USER_LOGIN_SUCCESS, payload: user });
})
.catch((e) => {
console.log(e);
});
});
Every time the user is successfully created and appears in the authorization section of firebase. And all of them will successfully execute the line dbRoot.doc(user.user.uid).set({ email });.
There is never an error logged to the console and it appears it should be running smoothly, however, the line dbRoot.doc(user.user.uid).set({ email }); will only work after the first try for every time I reload.
I had a .then promise chained to the line in question to check that it executed for the first one and it did every time, I really am not sure what I am doing wrong here and if the problem is with firestore. My security rules are on test mode so there shouldn't be any permission issues.