Replies: 2 comments
-
I haven't implemented custom logic like this, but according to their documentation, there doesn't seem to be a You could possibly check your backend if the user who is signing in is a new user (i.e. check a flag or last login date) and if it's a new user, you could process your new user logic like getting a referral code from a cookie, see: https://next-auth.js.org/configuration/initialization#advanced-initialization. I hope this helps! If you figure it out, could you let me know? This seems like a feat I would love to incorporate at some point! |
Beta Was this translation helpful? Give feedback.
-
I have a similar need—we have many types of users and they follow different paths through onboarding. I need to capture the intended type of the user when they are inserted into the database. I can do this via EmailProvider, but NextAuth seems to prevent me from setting or augmenting the |
Beta Was this translation helpful? Give feedback.
-
Good afternoon, I hope you are doing well.
I am looking for guidance to achieve a user creation flow for my needs. I couldn't realize how to do it yet by reading the docs, examples and the source code of the library.
I want to make a user referral system included in the "sign-up" flow. In our app we are using Google and Discord. The database we are using is Mongodb.
We have a route
/login
where the Google and Discord buttons to sign-in are shown. This flow is already working e2e. My intention is to have a query parameter like/login?referred=some_referral_code
. I am already passing the query param to the server API, and I am saving it into a short-lived cookie.The thing I couldn't figure out yet is where and/or how to intercept the user creation (first time ever a new user is shown in our database) to perform the checks for the referral code, the referredBy user, etc. And also how to include the referred code through the flow from the cookie.
Do you have any suggestion about how to achieve this? You can point me to some particular docs, examples.
Please let me know if I can provide you with more information to understand the context or whatever other extra useful info.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions