با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
میتوانید عملکردهایی را در پاسخ به ایجاد و حذف حسابهای کاربری Firebase فعال کنید. به عنوان مثال، می توانید یک ایمیل خوش آمدگویی برای کاربری ارسال کنید که به تازگی یک حساب کاربری در برنامه شما ایجاد کرده است. نمونههای موجود در این صفحه بر اساس نمونهای است که دقیقاً این کار را انجام میدهد - ایمیلهای خوشامدگویی و خداحافظی را پس از ایجاد و حذف حساب ارسال میکند.
حسابهای Firebase رویدادهای ایجاد کاربر را برای Cloud Functions هنگامی که:
کاربر یک حساب ایمیل و رمز عبور ایجاد می کند.
یک کاربر برای اولین بار با استفاده از یک ارائه دهنده هویت فدرال وارد سیستم می شود.
توسعه دهنده یک حساب کاربری با استفاده از Admin SDK ایجاد می کند.
یک کاربر برای اولین بار به یک جلسه احراز هویت ناشناس جدید وارد می شود.
هنگامی که کاربر برای اولین بار با استفاده از یک نشانه سفارشی وارد سیستم می شود، رویداد Cloud Functions فعال نمی شود.
دسترسی به ویژگی های کاربر
از دادههای کاربر که به عملکرد شما بازگردانده شدهاند، میتوانید به فهرست ویژگیهای کاربر موجود در شی UserRecord کاربر تازه ایجاد شده دسترسی داشته باشید. به عنوان مثال، می توانید ایمیل و نام نمایشی کاربر را مطابق شکل دریافت کنید:
همانطور که می توانید یک تابع را در ایجاد کاربر فعال کنید، می توانید به رویدادهای حذف کاربر نیز پاسخ دهید. همانطور که نشان داده شده است از کنترل کننده رویداد functions.auth.user().onDelete() استفاده کنید:
اگر Firebase Authentication with Identity Platform ارتقا داده اید، می توانید Firebase Authentication با استفاده از مسدود کردن Cloud Functions گسترش دهید.
توابع مسدود کردن به شما امکان می دهند کد سفارشی را اجرا کنید که نتیجه ثبت نام یا ورود کاربر به برنامه شما را تغییر می دهد. برای مثال، میتوانید از احراز هویت کاربر در صورت عدم رعایت معیارهای خاص جلوگیری کنید یا اطلاعات کاربر را قبل از بازگرداندن آن به برنامه مشتری خود بهروزرسانی کنید.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]