Next Auth unique Username with Social Login, best approach?
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
I am fairly new to Next Auth, I am struggling to find the best approach here.
I am requiring users to register with a username, email, and password.
With the social providers, when a user authorizes (lets say their github) for the first time, the user that is created seems to be storing
So if there are multiple users signing up using socials, multiple accounts will have this username of null which will throw an error when they are trying to sign up with social (since it thinks a username with "null" already exists). To fix this, I believe I could add a
I am requiring users to register with a username, email, and password.
With the social providers, when a user authorizes (lets say their github) for the first time, the user that is created seems to be storing
null for the username. This presents an issue, in my schema I have this outlined for the user:username String? @uniqueSo if there are multiple users signing up using socials, multiple accounts will have this username of null which will throw an error when they are trying to sign up with social (since it thinks a username with "null" already exists). To fix this, I believe I could add a
@default(uuid()) at the end of the schema property, but the ideal solution would be to direct the user using a social login (to register) and have them create a unique username. How would you normally approach this?2 Replies
Atlantic salmon
An easy way would be to either take their full name or email and generating a id out of it + extra numbers/chars in case of collision as a placeholder
Brewer's Blackbird
Have you found any solutions or approaches?