访问createUserWithEmailAndPassword方法中的firestore

时间:2018-02-06 07:57:49

标签: javascript firebase react-native firebase-authentication google-cloud-firestore

我正在使用expo / react native和firebase javascript web sdk构建应用程序。有人可以看看下面的代码,让我知道他们是否可以弄清楚为什么我的代码不起作用?当我使用expo开发模式时,代码工作正常,用户配置文件按预期设置。然而,在它发布的状态中它只是不起作用。新用户已创建并登录,但不会创建用户配置文件。

firebase.auth().signInWithEmailAndPassword(email, password)
.then(user => loginUserSuccess(dispatch, user))
.catch(() => {
  firebase.auth().createUserWithEmailAndPassword(email, password)
    .then((newUser) => {
        var userRef = firebase.firestore().collection("users").doc(newUser.uid);
        userRef.set({name: name, email: email, company: company, number: number, user: newUser.uid, adminEmail: '' })
        .then(function (){
          dispatch({ type: LOGIN_USER_SUCCESS, payload: newUser });
        })
        .catch(() => loginUserFail(dispatch)
        );
    })
    .catch(() => loginUserFail(dispatch));

我尝试了很多不同的方法,但仍然遇到同样的问题。根据文档,createUserWithEmailAndPassword方法返回用户凭据。我用调试语句确认了这一点,并检查我是否正在访问所述对象的uid属性。 感谢

0 个答案:

没有答案