0
0
Firebasecloud~10 mins

Why authentication identifies users in Firebase - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase Authentication.

Firebase
const auth = firebase.[1]();
Drag options to blanks, or click blank then click option'
AgetAuth
BinitializeAuth
CauthService
Dauth
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getAuth' which is modular SDK syntax.
Confusing initialization with other Firebase services.
2fill in blank
medium

Complete the code to sign in a user with email and password.

Firebase
firebase.auth().signInWithEmailAndPassword([1], password);
Drag options to blanks, or click blank then click option'
AuserEmail
Buser
Cemail
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' instead of 'email'.
Passing the password as the first argument.
3fill in blank
hard

Fix the error in the code to get the current authenticated user.

Firebase
const user = firebase.auth().[1];
Drag options to blanks, or click blank then click option'
AcurrentUser()
BcurrentUser
CgetCurrentUser()
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses after 'currentUser'.
Trying to call a non-existent method 'getCurrentUser()'.
4fill in blank
hard

Fill both blanks to listen for authentication state changes.

Firebase
firebase.auth().[1]((user) => {
  if (user) {
    console.log('User is [2]');
  }
});
Drag options to blanks, or click blank then click option'
AonAuthStateChanged
BsignedIn
CsignedOut
DauthStateChanged
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'authStateChanged' as a method instead of an event name.
Logging 'signedOut' when user is present.
5fill in blank
hard

Fill all three blanks to create a new user with email and password and handle errors.

Firebase
firebase.auth().createUserWithEmailAndPassword([1], [2])
  .then((userCredential) => {
    const user = userCredential.[3];
    console.log('User created:', user.email);
  })
  .catch((error) => {
    console.error(error.message);
  });
Drag options to blanks, or click blank then click option'
Aemail
Bpassword
Cuser
DuserInfo
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping email and password arguments.
Using 'userInfo' instead of 'user' property.