Add beforeSendEmail and beforeSendSms blocking functions samples#1253
Add beforeSendEmail and beforeSendSms blocking functions samples#1253macastelaz wants to merge 1 commit intofirebase:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces new Firebase Auth Blocking functions for both Node.js and Python quickstarts. It adds beforeEmailSent and beforeSmsSent triggers to block email sending to non-acme.com domains and SMS sending to non-US phone numbers. The review comments suggest minor readability improvements in the Node.js functions by explicitly checking for the existence of user.email and user.phoneNumber before calling string methods, even though optional chaining provides functional safety.
|
|
||
| // [START v2emailHttpsError] | ||
| // Only users of a specific domain can receive emails. | ||
| if (!user?.email?.includes("@acme.com")) { |
There was a problem hiding this comment.
Using optional chaining with includes on a potentially undefined email property is safe, but for better readability and explicit null checking, consider checking if the email exists before calling includes.
| if (!user?.email?.includes("@acme.com")) { | |
| if (user?.email && !user.email.includes("@acme.com")) { |
|
|
||
| // [START v2smsHttpsError] | ||
| // Only users of a specific region can receive SMS. | ||
| if (!user?.phoneNumber?.startsWith("+1")) { |
b71c7de to
d41d3a8
Compare
d41d3a8 to
b87ceec
Compare
Supplement samples in Node and Python to include examples of beforeSendEmail and beforeSendSms