Paths must be non-empty strings and can't contain “.”, “#”, “$”, “[”, or “]” [duplicate]

允我心安 提交于 2019-12-02 04:57:22

If you check the documentation of signInWithEmailAndPassword, you will see that it returns a UserCredential. Checking the documentation for that shows that it has no uid property, which explains why you get undefined.

You'll want to use authenticatedUser.user.uid, so:

this.fireAuth.signInWithEmailAndPassword(account[`email`], account[`password`]).then((userCredential) => {
  this.userProfile.child(userCredential.user.uid).set(
    account
  );
});

Creating a new user account with createUserWithEmailAndPassword automatically signs them in, so the nesting of those calls is not needed. If you (only) want to store the user profile when creating the account, createUserWithEmailAndPassword also returns a UserCredential. So there too, you need to indirect to user.uid:

return this.fireAuth.createUserWithEmailAndPassword(account[`email`], account[`password`]).then((userCredential) => {
  return this.userProfile.child(userCredential.user.uid).set(
    account
  );
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!