LuisCode3
LuisCode3
TTCTheo's Typesafe Cult
Created by LuisCode3 on 6/12/2023 in #questions
Next Auth unique Username with Social Login, best approach?
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 null for the username. This presents an issue, in my schema I have this outlined for the user: username String? @unique 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 @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?
4 replies