Methods

onCreate

onCreate(handler) returns functions.CloudFunction containing non-null functions.auth.UserRecord

Event handler that fires every time a Firebase Authentication user is created.

Parameter

handler

function(non-null functions.Event containing non-null functions.auth.UserRecord)

Event handler that runs every time a Firebase Authentication user is created.

Value must not be null.

Returns

non-null functions.CloudFunction containing non-null functions.auth.UserRecord A Cloud Function you can export.

Example

exports.sendWelcomeEmail = functions.auth.user().onCreate(function(event) {
  // Get the uid and display name of the newly created user.
  var uid = event.data.uid;
  var displayName = event.data.displayName;

  // Send a welcome email to the newly created user.
  // The sendEmail() method is left as an exercise to the reader.
  return sendEmail(uid, displayName);
});

onDelete

onDelete(handler) returns functions.CloudFunction containing non-null functions.auth.UserRecord

Event handler that fires every time a Firebase Authentication user is deleted.

Parameter

handler

function(non-null functions.Event containing non-null functions.auth.UserRecord)

Event handler that runs run every time a Firebase Authentication user is deleted.

Returns

non-null functions.CloudFunction containing non-null functions.auth.UserRecord A Cloud Function you can export.

Example

exports.removeUserFromDatabase = functions.auth.user().onDelete(function(event) {
  // Get the uid of the deleted user.
  var uid = event.data.uid;

  // Remove the user from your Realtime Database's /users node.
  return admin.database().ref("/users/" + uid).remove();
});