Custom Emails and Auth Handling
I'm trying to create a door to door sales flow that creates a customer's account in the app, and then sends them a welcome email with a link to create their password. Does Wasp expose any internal methods to create password reset tokens that I can use in my own custom email sending logic? I don't want to rely on the Password Reset Request flow because it sends an email for Password Reset. Which is not the goal in this case.
5 Replies
Hi @JLegendz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Wasp does not currently document or explicitly expose a public internal method for generating password reset tokens independently of the standard password reset flow. The documented approach for sending password reset links relies on the built-in password reset flow, which is designed to send a "password reset" email, not a "set your password for the first time" or "welcome" email. The available methods, such as requestPasswordReset and resetPassword, are tied to this flow and its associated email content and UI components, as described in the docs Password Reset Flow and PasswordResetConfig.
However, Wasp does allow you to customize the content of the password reset email by providing your own getEmailContentFn, but this still operates within the password reset context and does not provide a separate "invite" or "set password" token generation API.
If you want to implement a custom flow (e.g., sending a welcome email with a link to set a password), you would likely need to create your own logic for generating a secure, single-use token, storing it, and handling the password creation endpoint. The knowledge sources do not provide a ready-made Wasp helper for this use case.
There is an open issue in the Wasp repository discussing the need for higher-level helper functions to make custom flows easier and more secure, but as of now, this is not yet implemented or documented for your specific scenario Rewrite
I'm sorry, but the knowledge sources do not indicate that Wasp currently exposes an internal method specifically for generating password reset tokens for use in custom email flows outside the standard password reset process. You would need to implement this logic yourself for now. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @JLegendz, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
email
auth to use more higher-level helper functions.
In summary:I'm sorry, but the knowledge sources do not indicate that Wasp currently exposes an internal method specifically for generating password reset tokens for use in custom email flows outside the standard password reset process. You would need to implement this logic yourself for now. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @JLegendz, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
did this help @JLegendz ? I think the bot is mostly right. Maybe @martinsos has a tip to add here.
Let's see what the master of auth, @miho, says about it!
1. I'd probably restrict the signup first by using the
onBeforeSignup
hook i.e. just throw an error: https://wasp.sh/docs/auth/auth-hooks#the-onbeforesignup-hook
2. Then, I'd have a custom signup action that you control that sends the email. You can use the sendPasswordResetEmail
function :
Auth Hooks | Wasp
Auth hooks allow you to "hook into" the auth process at various stages and run your custom code. For example, if you want to forbid certain emails from signing up, or if you wish to send a welcome email to the user after they sign up, auth hooks are the way to go.
@martinsos we really need a public API overview in the docs! 😄