Auth Hooks: Welcome email sent twice (onAfterSignup + onAfterEmailVerified)
Hey!
I need your help about how to handle the Auth Hooks.
I’m trying to send a welcome email once a user has successfully created and verified their account. I support both Email and Google authentication.
At first, I thought I’d need to use both onAfterEmailVerified (for the Email workflow) and onAfterSignup with a check like
if (oauth && user.email)
if (oauth && user.email)
(for the Google workflow). But it seems that both hooks are firing, and the email ends up being sent twice.
I’m sharing my logs below — thanks in advance for your help!
[ Server ] [20:34:12.176] INFO (10789): Starting [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterSignup" [ Server ] [20:34:12.196] INFO (10789): Finished [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterSignup"
[ Server ] [20:34:55.169] INFO (10789): Starting [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterEmailVerified" [ Server ] [20:34:55.283] INFO (10789): Starting [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterEmailVerified" [ Server ] [20:34:56.198] INFO (10789): Finished [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterEmailVerified" [ Server ] [20:34:56.200] INFO (10789): request completed [ Server ] req: { [ Server ] "method": "POST", [ Server ] "url": "/auth/email/verify-email", [ Server ] "requestId": "f4a23756-77ad-4a42-a838-792b42079656" [ Server ] } [ Server ] res: { [ Server ] "statusCode": 200 [ Server ] } [ Server ] responseTime: 1111 [ Server ] [20:34:56.300] INFO (10789): Finished [ Server ] user: "a71d655a-ee8e-43ac-b371-06348adda235" [ Server ] operation: "onAfterEmailVerified"