Skip to content

Conversation

@blidd-google
Copy link
Contributor

@blidd-google blidd-google commented Nov 28, 2023

GCIP now supports a new event type that triggers before emails are sent using Identity Platform. This PR adds a new trigger to respond to the beforeSendEmail event type. Based on changes from blidd.blocking-fn-email.

Copy link
Contributor

@Xiaoshouzi-gh Xiaoshouzi-gh left a comment

Choose a reason for hiding this comment

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

Overall LGTM, only nit comments.

emailType?: EmailType;
}

/** Defines the auth event for 2nd gen blocking events */
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a comment say that for beforeEmailSent and beforeSmsSent, this field will be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't this field be defined for beforeEmailSent?

Copy link
Contributor

Choose a reason for hiding this comment

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

typo, this should be undefined for beforeCreate and beforeSignIn events. May be a comment saying this value is only available for beforeEmailSent trigger.

export interface DecodedPayloadUserRecord {
uid: string;
email?: string;
email_type?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

we do not need email_type in the userrecord correct?

: await auth.getAuth(getApp())._verifyAuthBlockingToken(req.body.data.jwt, "run.app");
const authUserRecord = parseAuthUserRecord(decodedPayload.user_record);
let authUserRecord: AuthUserRecord | undefined;
if (decodedPayload.user_record) {
Copy link
Contributor

Choose a reason for hiding this comment

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

may be we should use decodedPayload.event_type value in the if statement. This helps eliminate the backend error.


const BEFORE_EMAIL_TRIGGER = {
eventType: "providers/cloud.auth/eventTypes/user.beforeSendEmail",
options: {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove the options here. See comments in v2/providers/identity.ts

Copy link
Contributor

@Xiaoshouzi-gh Xiaoshouzi-gh left a comment

Choose a reason for hiding this comment

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

LGTM with nit comments

emailType?: EmailType;
}

/** Defines the auth event for 2nd gen blocking events */
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, this should be undefined for beforeCreate and beforeSignIn events. May be a comment saying this value is only available for beforeEmailSent trigger.

@blidd-google
Copy link
Contributor Author

Changes merged in #1621.

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

Labels

None yet

2 participants