0
0
Firebasecloud~10 mins

Password reset flow 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 send a password reset email using Firebase Authentication.

Firebase
firebase.auth().[1]('user@example.com')
Drag options to blanks, or click blank then click option'
AsignOut
BsignInWithEmailAndPassword
CcreateUserWithEmailAndPassword
DsendPasswordResetEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using signInWithEmailAndPassword instead of sendPasswordResetEmail
Trying to create a user instead of resetting password
2fill in blank
medium

Complete the code to handle the promise returned by sending a password reset email.

Firebase
firebase.auth().sendPasswordResetEmail('user@example.com').[1](() => { console.log('Email sent'); })
Drag options to blanks, or click blank then click option'
Afinally
Bthen
Ccatch
Dsubscribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using catch instead of then for success handling
Using subscribe which is not a promise method
3fill in blank
hard

Fix the error in the code to properly catch errors when sending a password reset email.

Firebase
firebase.auth().sendPasswordResetEmail('user@example.com').then(() => { console.log('Email sent'); }).[1]((error) => { console.error(error.message); })
Drag options to blanks, or click blank then click option'
Acatch
Bthen
Cfinally
Dsubscribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using then instead of catch for error handling
Using finally which runs regardless of success or failure
4fill in blank
hard

Fill both blanks to create a function that sends a password reset email and logs success or error.

Firebase
function resetPassword(email) {
  firebase.auth().[1](email).then(() => {
    console.log('Reset email sent');
  }).[2]((error) => {
    console.error('Error:', error.message);
  });
}
Drag options to blanks, or click blank then click option'
AsendPasswordResetEmail
BsignInWithEmailAndPassword
Ccatch
Dthen
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping then and catch methods
Using signInWithEmailAndPassword instead of sendPasswordResetEmail
5fill in blank
hard

Fill all three blanks to create an async function that sends a password reset email and handles errors with try-catch.

Firebase
async function resetPasswordAsync(email) {
  try {
    await firebase.auth().[1](email);
    console.log([2]);
  } catch (error) {
    console.error([3]);
  }
}
Drag options to blanks, or click blank then click option'
AsendPasswordResetEmail
B'Password reset email sent'
Cerror.message
DsignOut
Attempts:
3 left
💡 Hint
Common Mistakes
Using signOut instead of sendPasswordResetEmail
Logging error object directly instead of error.message
Not using await with the async function