0
0
Firebasecloud~20 mins

Authentication trigger functions in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Authentication Trigger Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this Firebase Authentication trigger function?
Consider this Firebase Cloud Function that triggers when a user is created. What will be logged when a new user with email 'user@example.com' is created?
Firebase
exports.userCreated = functions.auth.user().onCreate((user) => {
  console.log(`New user created: ${user.email}`);
  return null;
});
ANew user created: user@example.com
BNew user created: undefined
CError: user.email is not defined
DNo output is logged
Attempts:
2 left
💡 Hint
The user object passed to the trigger contains the user's email property.
🧠 Conceptual
intermediate
1:30remaining
Which Firebase Authentication trigger runs when a user deletes their account?
Firebase Authentication provides triggers for user lifecycle events. Which trigger function runs when a user deletes their account?
Afunctions.auth.user().onDestroy()
Bfunctions.auth.user().onRemove()
Cfunctions.auth.user().onDelete()
Dfunctions.auth.user().onExpire()
Attempts:
2 left
💡 Hint
The trigger name includes 'Delete' for account deletion.
📝 Syntax
advanced
2:30remaining
Identify the syntax error in this Firebase Authentication trigger function
Which option contains the correct syntax for a Firebase Authentication onCreate trigger function?
Firebase
exports.newUser = functions.auth.user().onCreate((user) => {
  console.log('User created:', user.uid);
  return null;
});
A
exports.newUser = functions.auth.user().onCreate((user) => {
  console.log('User created:', user.uid);
  return null;
}
B
exports.newUser = functions.auth.user().onCreate((user) => {
  console.log('User created:', user.uid)
  return null;
});
C
exports.newUser = functions.auth.user().onCreate(user => {
  console.log('User created:', user.uid);
  return null;
});
D
exports.newUser = functions.auth.user().onCreate((user) => {
  console.log('User created:', user.uid);
  return null;
});
Attempts:
2 left
💡 Hint
Check for missing semicolons and balanced brackets.
optimization
advanced
2:00remaining
How to optimize a Firebase Authentication onCreate trigger to minimize cold start time?
You want your Firebase Authentication onCreate trigger to run quickly when a user signs up. Which practice helps reduce cold start delays?
AUse global imports and initialize heavy libraries outside the trigger function
BImport only necessary modules inside the trigger function, not globally
CWrite all code inside the trigger function without external imports
DAvoid using async/await in the trigger function
Attempts:
2 left
💡 Hint
Cold start is affected by how much code loads before the function runs.
🔧 Debug
expert
3:00remaining
Why does this Firebase Authentication onDelete trigger fail to run?
Given this code, why does the onDelete trigger not execute when a user deletes their account? exports.userDeleted = functions.auth.user().onDelete((user) => { console.log('User deleted:', user.uid); return null; });
AThe user parameter is undefined in onDelete triggers
BThe function is not deployed to Firebase after code changes
CThe trigger should be onRemove, not onDelete
DFirebase Authentication does not support onDelete triggers
Attempts:
2 left
💡 Hint
Check if the function is active in your Firebase project.