0
0
Firebasecloud~10 mins

Anonymous authentication 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 anonymously using Firebase Authentication.

Firebase
firebase.auth().[1]()
Drag options to blanks, or click blank then click option'
AsignInAnonymously
BsignOut
CcreateUserWithEmailAndPassword
DsignInWithEmailAndPassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using signInWithEmailAndPassword instead of signInAnonymously.
Trying to create a user with email and password for anonymous sign-in.
2fill in blank
medium

Complete the code to check if the current user is signed in anonymously.

Firebase
const user = firebase.auth().currentUser;
if (user && user.[1]) {
  console.log('User is anonymous');
}
Drag options to blanks, or click blank then click option'
AisSignedIn
BisAnonymous
Canonymous
DisGuest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent property like isSignedIn or isGuest.
Checking user.anonymous instead of user.isAnonymous.
3fill in blank
hard

Fix the error in the code to handle anonymous sign-in errors correctly.

Firebase
firebase.auth().signInAnonymously()
  .then(() => {
    console.log('Signed in anonymously');
  })
  .catch(error => {
    console.error('Error code:', [1]);
  });
Drag options to blanks, or click blank then click option'
Aerror.message
Berror.status
Cerror.code
Derror.reason
Attempts:
3 left
💡 Hint
Common Mistakes
Using error.message instead of error.code for error codes.
Using non-existent properties like error.status or error.reason.
4fill in blank
hard

Fill both blanks to link an anonymous user to an email/password account.

Firebase
const credential = firebase.auth.EmailAuthProvider.[1](email, password);
firebase.auth().currentUser.[2](credential)
  .then(() => console.log('Account linked'))
  .catch(error => console.error(error));
Drag options to blanks, or click blank then click option'
Acredential
BlinkWithCredential
CsignInWithCredential
DcreateCredential
Attempts:
3 left
💡 Hint
Common Mistakes
Using signInWithCredential instead of linkWithCredential for linking accounts.
Using createCredential which is not a Firebase method.
5fill in blank
hard

Fill both blanks to sign out the current user and then sign in anonymously again.

Firebase
firebase.auth().[1]()
  .then(() => firebase.auth().[2]())
  .then(() => console.log('Signed out and signed in anonymously'))
  .catch(error => console.error(error));
Drag options to blanks, or click blank then click option'
AsignOut
BsignInAnonymously
CsignInWithEmailAndPassword
DcreateUserWithEmailAndPassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using signInWithEmailAndPassword instead of signInAnonymously for anonymous sign-in.
Not signing out before signing in anonymously again.