convex auth OTP email customisation
Below is the code from the doc to send an OTP email to users with convex auth.
I have a multi tenant app and I wonder if I can customise the from part. Ideally, retrieve the domain origin from where the request came from and then query the database to retrieve the right tenant and finally customise the from part?
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
sendVerificationRequest
has an action ctx as an undocumented second param. Typescript will yell at you so you'll have to have it expect an error there. You can check it out here: https://github.com/get-convex/convex-auth/blob/e4a9e0e7de0da9160185ac0028cfb684a9bcd147/src/server/implementation/signIn.ts#L166-L168
You'll need to assert it's type using ActionCtx from your generated server code.
I haven't used it, but looking at the code it should work.Oh that's cool! Thanks.
Then to identify the tenant with the origin of the request, I have added the redirectTo params on the signIn method, put the SITE_URL setup with convex-auth and added a origin query param that I can retrieve from the url args from the like so
Client side:
Convex side: