How can I support multiple user types using EmailProvider? #4045
Replies: 1 comment 1 reply
-
I'm also curious about this. In some issue @balazsorban44 says to not use
But
I get there's no single correct answer because it depends on the final flow: with registration / without registration, etc. But IMO, the universal answer, in many cases, is to override
https://next-auth.js.org/tutorials/creating-a-database-adapter contains no descriptions of what callbacks are meant to do (hinting it's for advanced users only). Docs don't mention how easy (and useful!) is to override adapter methods. Etc, etc. Adapters should receive more priority in the docs. For example, this document https://next-auth.js.org/adapters/models helped me to understand how NextAuth works much better than all shallow tutorials here https://next-auth.js.org/tutorials I was initially very confused about the difference between |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
When the user first “registers” (i.e. verifies) their email using the
EmailProvider
, I’d like to add a couple additional fields to the form. I’d then like this to carry these through to the user creation, but having a lot of trouble doing this.I plan to have two user types. You can think of them as:
consumer
service_provider
Initially I only want to allow
UserType.service_provider
users signing up, and then will present them with custom pages and functionality when they log in (different from normal users).I’ve been able to get a hold of the request object and pass that into a custom
PrismaAdapterWithRequest
. This let’s me store the user type on the verification request… this is great, but how can I connect the dots tocreateUser
?I was hoping for a built-in way to do this, but
EmailProvider
appears more limited than others. One idea I suppose is to tack this onto the verification/callback url, but that seems kinda dirty?Seems like modifying some of the internals of
packages/next-auth/src/core/routes/callback.ts
could work. Happy to do it if you provide guidance!How to reproduce ☕️
Provided the context above. LMK if there’s anything else.
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions