[null,null,["最后更新时间 (UTC):2025-08-13。"],[],[],null,["\u003cbr /\u003e\n\nYou can trigger functions in response to the creation and deletion of\nFirebase user accounts. For example, you could send a welcome email to a\nuser who has just created an account in your app. Examples on this page are\nbased on a sample that does exactly this---sends welcome and farewell emails\nupon account creation and deletion.\n\nFor more examples of use cases, see\n[What can I do with Cloud Functions?](/docs/functions/use-cases).\n| **Note:** Cloud Functions for Firebase (2nd gen) does not provide support for the events and triggers described in this guide. Because 1st gen and 2nd gen functions can coexist side-by-side in the same source file, you can still develop and deploy this functionality together with 2nd gen functions.\n\nTrigger a function on user creation\n\nYou can create a function that triggers when a Firebase user is\ncreated using the\n[`functions.auth.user().onCreate()`](/docs/reference/functions/firebase-functions.auth.userbuilder#authuserbuilderoncreate)\nevent handler:\n\n\u003cbr /\u003e\n\n```gdscript\nexports.sendWelcomeEmail = functions.auth.user().onCreate((user) =\u003e {\n // ...\n});\n```\n\n\u003cbr /\u003e\n\nFirebase accounts will trigger user creation events for\nCloud Functions when:\n\n- A user creates an email account and password.\n- A user signs in for the first time using a federated identity provider.\n- The developer creates an account using the Admin SDK.\n- A user signs in to a new anonymous auth session for the first time.\n\nA Cloud Functions event is *not* triggered when a user signs in for the\nfirst time using a custom token.\n\nAccess user attributes\n\nFrom the user data returned to your function, you can\naccess the list of user attributes available in the newly created user's\n[`UserRecord`](/docs/reference/functions/firebase-functions.auth#authuserrecord)\nobject. For example, you can get the user's email and display name as shown:\n\n\u003cbr /\u003e\n\n```gdscript\nconst email = user.email; // The email of the user.\nconst displayName = user.displayName; // The display name of the user.https://github.com/firebase/functions-samples/blob/c4fde45b65fab584715e786ce3264a6932d996ec/Node-1st-gen/quickstarts/email-users/functions/index.js#L48-L49\n```\n\n\u003cbr /\u003e\n\nTrigger a function on user deletion\n\nJust as you can trigger a function on user creation, you can\nrespond to user deletion events. Use the\n[`functions.auth.user().onDelete()`](/docs/reference/functions/firebase-functions.auth.userbuilder#authuserbuilderondelete)\nevent handler as shown:\n\n\u003cbr /\u003e\n\n```gdscript\nexports.sendByeEmail = functions.auth.user().onDelete((user) =\u003e {\n // ...\n});\n```\n\n\u003cbr /\u003e\n\n| **Caution:** Deleting multiple users at once using the Firebase Admin SDK (for example, `admin.auth().deleteUsers([uid1, uid2])` in Node.js) does not fire user deletion events, so event handlers set up using `functions.auth.user().onDelete()` *will not be triggered*. Delete users one at a time if you want user deletion events to fire for each deleted user.\n\nTrigger blocking functions\n\nIf you've upgraded to Firebase Authentication with Identity Platform, you can extend Firebase Authentication using\n[blocking Cloud Functions](/docs/auth/extend-with-blocking-functions).\n\nBlocking functions let you execute custom code that modifies the result of a\nuser registering or signing in to your app. For example, you can prevent a user\nfrom authenticating if they don't meet certain criteria, or update a user's\ninformation before returning it to your client app."]]