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
);
});