Can I create a user with only an email?
TLDR: I want to create an user only knowing the email in advance in order to allow users to pay without having to log in, just provide their email.
I'm building an app that requires an extensive survey, in order to reduce friction the last step on my survey is asking the user for an email. After that I would like to show a paywall and allow the user to pay / subscribe without ever having to officially create an account. After payment I will redirect to account creation etc.
is that possible?
8 Replies
Hi @brahyammm. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, it is possible to create a user with only an email in Wasp. You can create a custom sign-up action that only requires an email. Here's how you can do it:
First, you need to define a custom sign-up action in your
main.wasp
file:
Source: Wasp Docs (https://wasp-lang.dev/docs/auth/email#creating-a-custom-sign-up-action)
Then, in your src/auth/signup.js
file, you can define the signup
function that only requires an email:
Source: Wasp Docs (https://wasp-lang.dev/docs/auth/email#creating-a-custom-sign-up-action)
This will create a new user with only an email and send them a verification email. After the user verifies their email, they can proceed to create a password and complete their account creation.
Please note that this approach requires the user to verify their email before they can complete their account creation. If you want to allow users to pay/subscribe without verifying their email, you might need to modify this approach.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @brahyammm, 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?The bot made some stuff up here beware! 😄
Sounds possible with the above approach by skipping the email verification right?
What Kapa talked about here is a bit too optimistic, I don't it would work with Wasp in that form.
What you can do of course is - have two entities / tables -
User
for auth and Customer
that has on it an email
and hasPaid
fields. Do the process without auth first and rely on the Customer
entity.
Later on when they create an account, it will create an User
entity for them and you can then use the onAfterSignup
auth hook to connect the User
and Customer
entities 🙂oh nice!, Im gonna give that a try
In the suggestion above, you are doing your flow without auth, but later on getting the benefits of the Wasp's auth system 😄
thank you
Of course, you can go more custom like Kapa suggested above, feel free to experiment! Good luck 😄