My application only uploads to database after first account?

爷,独闯天下 提交于 2019-12-11 15:54:18

问题


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.

来源:https://stackoverflow.com/questions/57583341/my-application-only-uploads-to-database-after-first-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!