0
0
Firebasecloud~10 mins

User session management in Firebase - Interactive Code Practice

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

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

Firebase
firebase.auth().signInWithEmailAndPassword(email, [1])
Drag options to blanks, or click blank then click option'
Atoken
Busername
Cpassword
DsessionId
Attempts:
3 left
💡 Hint
Common Mistakes
Using username instead of password
Using token instead of password
2fill in blank
medium

Complete the code to check if a user is currently signed in.

Firebase
const user = firebase.auth().[1];
Drag options to blanks, or click blank then click option'
AcurrentUser
BactiveUser
CsignedInUser
DuserSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using activeUser which does not exist
Using userSession which is not a Firebase property
3fill in blank
hard

Fix the error in the code to sign out the current user.

Firebase
firebase.auth().[1]();
Drag options to blanks, or click blank then click option'
AsignOut
BsignIn
Clogout
DendSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using signIn instead of signOut
Using logout or endSession which are not Firebase methods
4fill in blank
hard

Fill both blanks to listen for changes in the user's authentication state.

Firebase
firebase.auth().[1]((user) => {
  if (user) {
    console.log('User is signed in:', [2]);
  } else {
    console.log('No user signed in');
  }
});
Drag options to blanks, or click blank then click option'
AonAuthStateChanged
BcurrentUser
Cuser
DauthListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using currentUser instead of onAuthStateChanged
Logging currentUser instead of the callback parameter
5fill in blank
hard

Fill all three blanks to refresh the user's ID token.

Firebase
firebase.auth().currentUser.[1]().then(([2]) => {
  console.log('New token:', [3]);
});
Drag options to blanks, or click blank then click option'
AgetIdToken
Btoken
DrefreshToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using refreshToken method which does not exist
Using different variable names inconsistently