Complete the code to define a Firebase Authentication trigger for user creation.
exports.userCreated = functions.auth.user().[1]((user) => { console.log('User created:', user.uid); });
The onCreate method triggers the function when a new user is created.
Complete the code to define a Firebase Authentication trigger for user deletion.
exports.userDeleted = functions.auth.user().[1]((user) => { console.log('User deleted:', user.uid); });
The onDelete method triggers the function when a user is deleted.
Fix the error in the code to correctly trigger on user creation.
exports.newUser = functions.auth.user().[1]((user) => { console.log('New user ID:', user.uid); });
The correct trigger for user creation is onCreate. Using onDelete or others will not trigger on creation.
Fill both blanks to log the user's email and UID when a user is deleted.
exports.logDeletedUser = functions.auth.user().[1]((user) => { console.log('Deleted user email:', user.[2]); });
The trigger onDelete runs when a user is deleted. The user's email is accessed with user.email.
Fill all three blanks to create a trigger that logs the user's UID, email, and creation time when a user is created.
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); });
The trigger onCreate runs when a user is created. The user's UID and email are accessed with user.uid and user.email.