Add default username to User on signup? #4502
Unanswered
dasveloper
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Next Auth with Prisma, and Email, Google, and Facebook providers. I'd like all users to have default unique
username
, something like 'User-1', 'User-2', etc. or 'User-ABCD', and allow users to update their username later. I'm wondering where is the best place to add this logic?I've added the property to my User model:
username String @unique
But I can't figure out where I should catch the signup from any provider, generate the username, and then save it then DB? I can do it in the
createUser
event like this:But it seems like events should really be for simple logging and stuff not new DB calls with sideeffects? Plus there is a chance it could fail and then the user wouldn't get a default which could be problematic.
Beta Was this translation helpful? Give feedback.
All reactions