0
0
Firebasecloud~10 mins

Authentication trigger functions 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 define a Firebase Authentication trigger for user creation.

Firebase
exports.userCreated = functions.auth.user().[1]((user) => {
  console.log('User created:', user.uid);
});
Drag options to blanks, or click blank then click option'
AonWrite
BonDelete
ConCreate
DonUpdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using onDelete instead of onCreate triggers on user deletion.
Using onUpdate triggers on user data changes, not creation.
2fill in blank
medium

Complete the code to define a Firebase Authentication trigger for user deletion.

Firebase
exports.userDeleted = functions.auth.user().[1]((user) => {
  console.log('User deleted:', user.uid);
});
Drag options to blanks, or click blank then click option'
AonDelete
BonCreate
ConUpdate
DonWrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using onCreate instead of onDelete triggers on user creation.
Using onUpdate triggers on user data changes, not deletion.
3fill in blank
hard

Fix the error in the code to correctly trigger on user creation.

Firebase
exports.newUser = functions.auth.user().[1]((user) => {
  console.log('New user ID:', user.uid);
});
Drag options to blanks, or click blank then click option'
AonCreate
BonUpdate
ConDelete
DonWrite
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing onCreate with onDelete or onUpdate triggers.
Using onWrite which is not a valid auth trigger.
4fill in blank
hard

Fill both blanks to log the user's email and UID when a user is deleted.

Firebase
exports.logDeletedUser = functions.auth.user().[1]((user) => {
  console.log('Deleted user email:', user.[2]);
});
Drag options to blanks, or click blank then click option'
AonDelete
BonCreate
Cemail
Duid
Attempts:
3 left
💡 Hint
Common Mistakes
Using onCreate instead of onDelete for deletion triggers.
Accessing user.uid instead of user.email when email is needed.
5fill in blank
hard

Fill all three blanks to create a trigger that logs the user's UID, email, and creation time when a user is created.

Firebase
exports.logNewUser = functions.auth.user().[1]((user) => {
  console.log('User ID:', user.[2]);
  console.log('Email:', user.[3]);
  console.log('Created at:', user.metadata.creationTime);
});
Drag options to blanks, or click blank then click option'
AonCreate
Buid
Cemail
DonDelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using onDelete instead of onCreate for creation triggers.
Mixing up user.uid and user.email properties.