Skip to content

Commit b2a0792

Browse files
authored
Update email.js
The promises for `signInWithEmailAndPassword` and `createUserWithEmailAndPassword` resolve with a `UserCredential` and not a user. Calling the parameter `user` is a left-over from the old (pre-5.0) SDK where it was an actual `FirebaseUser` object. I renamed the parameter and added an example of how to access the UID, which is the most common action for developers after creating an account/signing in.
1 parent c0ca18d commit b2a0792

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

auth/email.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ function signInWithEmailPassword() {
99
var password = "hunter2";
1010
// [START auth_signin_password]
1111
firebase.auth().signInWithEmailAndPassword(email, password)
12-
.then((user) => {
13-
// Signed in
12+
.then((userCredential) => {
13+
// Signed in
14+
console.log(userCredential.user.uid);
1415
// ...
1516
})
1617
.catch((error) => {
@@ -25,8 +26,9 @@ function signUpWithEmailPasswoerd() {
2526
var password = "hunter2";
2627
// [START auth_signup_password]
2728
firebase.auth().createUserWithEmailAndPassword(email, password)
28-
.then((user) => {
29+
.then((userCredential) => {
2930
// Signed in
31+
console.log(userCredential.user.uid);
3032
// ...
3133
})
3234
.catch((error) => {

0 commit comments

Comments
 (0)