Skip to content

Auth sample for 2nd gen - #1311

Open
jhuleatt wants to merge 9 commits into
firebase:mainfrom
jhuleatt:2nd-gen-auth
Open

Auth sample for 2nd gen#1311
jhuleatt wants to merge 9 commits into
firebase:mainfrom
jhuleatt:2nd-gen-auth

Conversation

@jhuleatt

@jhuleatt jhuleatt commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Samples for onUserCreated, onUserDeleted, and multi-tenancy with GCIP.

Snippets are in these files:

Node/quickstarts/email-users/functions/tenants.js
Node/quickstarts/email-users/functions/sendWelcomeEmail.js
Node/quickstarts/email-users/functions/sendByeEmail.js

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a Node.js 2nd generation quickstart sample for Firebase Auth triggers that sends welcome and goodbye emails using Resend. Key feedback includes fixing a copy-paste logic error in sendGoodbyeEmail where a welcome greeting is used, adding guard clauses to handle users without email addresses in the email service, regenerating the lockfile to correctly lock resend instead of nodemailer, and removing a leftover TypeScript compile script from package.json.

Comment thread Node/quickstarts/email-users/functions/utils/myEmailService.js Outdated
Comment thread Node/quickstarts/email-users/functions/pnpm-lock.yaml Outdated
Comment thread Node/quickstarts/email-users/functions/utils/myEmailService.js Outdated
Comment thread Node/quickstarts/email-users/functions/package.json
Comment thread Node/quickstarts/email-users/functions/tenants.js
Comment thread Node/quickstarts/email-users/functions/newUserWelcome.js

@egilmorez egilmorez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question one observation, thanks!

@shettyvarun268 shettyvarun268 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes. Thanks for the PR Jeff

Comment thread Node/quickstarts/email-users/functions/sendWelcomeEmail.js Outdated
Comment thread Node/quickstarts/email-users/functions/tenants.js Outdated
},
"dependencies": {
"firebase-admin": "^14.2.0",
"firebase-functions": "^7.3.2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These features will most likely be released on version 7.4.0. We might want to bump this up before final release.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Varun is correct. For testing purposes we have the code usable in 7.3.3-rc.2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^7.3.2 will pick up minor updates, so I'll leave as-is for now and update all samples to 7.4.0 when it is released

Comment thread Node/quickstarts/email-users/functions/utils/myEmailService.js Outdated

@shettyvarun268 shettyvarun268 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. LGTM

@ajperel ajperel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important that we fix firebase-functions version and one other suggestion, but I trust you to make these changes before merging.

/**
* Deletes one inactive user from the list.
* @param {admin.auth.UserRecord[]} inactiveUsers
* @param {import("firebase-admin/auth").UserRecord[]} inactiveUsers

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these inline imports are pretty ugly and. wouldn't want a user to do this. Can't you import UserRecord once at the beginning of this file and then use it throughout?

},
"dependencies": {
"firebase-admin": "^14.2.0",
"firebase-functions": "^7.3.2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be updated to ^7.4.0 when we merge. That should be the version we publish with the events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants