קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אתם יכולים להפעיל פונקציות בתגובה ליצירה ולמחיקה של Firebase חשבונות משתמשים. לדוגמה, אפשר לשלוח אימייל של ברוכים הבאים למשתמש שיצר חשבון באפליקציה שלכם. הדוגמאות בדף הזה מבוססות על דוגמה שעושה בדיוק את זה – שולחת אימיילים של ברוכים הבאים ושל פרידה כשיוצרים חשבון וכשמוחקים אותו.
חשבונות Firebase יפעילו אירועים של יצירת משתמשים עבור Cloud Functions במקרים הבאים:
משתמש יוצר חשבון אימייל וסיסמה.
משתמש נכנס לחשבון בפעם הראשונה באמצעות ספק זהויות מאוחד.
המפתח יוצר חשבון באמצעות Admin SDK.
משתמש נכנס בפעם הראשונה לסשן חדש של אימות אנונימי.
אירוע Cloud Functionsלא מופעל כשמשתמש נכנס לחשבון בפעם הראשונה באמצעות טוקן מותאם אישית.
גישה למאפייני משתמש
מנתוני המשתמש שמוחזרים לפונקציה, אפשר לגשת לרשימת מאפייני המשתמש שזמינים באובייקט UserRecord של המשתמש שנוצר. לדוגמה, אפשר לקבל את האימייל והשם המוצג של המשתמש כמו שמוצג כאן:
בדיוק כמו שאפשר להפעיל פונקציה כשמשתמש נוצר, אפשר להגיב לאירועים של מחיקת משתמשים. משתמשים ב-event handler
functions.auth.user().onDelete()
כמו שמוצג כאן:
אם שדרגתם ל-Firebase Authentication with Identity Platform, אתם יכולים להאריך את Firebase Authentication באמצעות חסימת Cloud Functions.
פונקציות חסימה מאפשרות להריץ קוד מותאם אישית שמשנה את התוצאה של משתמש שנרשם לאפליקציה או נכנס אליה. לדוגמה, אפשר למנוע ממשתמש לעבור אימות אם הוא לא עומד בקריטריונים מסוימים, או לעדכן את פרטי המשתמש לפני שהם מוחזרים לאפליקציית הלקוח.
[[["התוכן קל להבנה","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-09 (שעון UTC)."],[],[],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."]]