Choose username and extra data when signup/login with OAuth
Unanswered
Pacific herring posted this in #help-forum
Pacific herringOP
Okay my problem is not directly a NextJS issue. Im using Appwrite, backend as service like Firebase so I guess its "same" and a common problem. I have a NextJS app with users that have unique usernames (stored in a 'user' collection). Thus, during registration, they choose their user name among the other inputs of the form. But when you register/login via OAuth, it is impossible to set this username. How to deals with ? The only way that ive found to solve the problem is when u login, there is a check if user.username exists. If not, a modal open to let the user add his username. But it's a bit "handmade" isn't it?
6 Replies
Golden-winged Warbler
typically, one would use the email as the username with OAuth, until the user sets it manually. This is very application specific, so you can use a modal at registration like you mention, or you can let them change it some on boarding workflow (after registration) or any time in settings.
You may be able to do something with the callback url / parameters (generally) not sure with Next / whatever auth setup you are using
You may be able to do something with the callback url / parameters (generally) not sure with Next / whatever auth setup you are using
@Golden-winged Warbler typically, one would use the email as the username with OAuth, until the user sets it manually. This is very application specific, so you can use a modal at registration like you mention, or you can let them change it some on boarding workflow (after registration) or any time in settings.
You may be able to do something with the callback url / parameters (generally) not sure with Next / whatever auth setup you are using
Pacific herringOP
Ive check how Twitter managed the signup with OAuth
And they create a default username based on the name. Like if the name is Brad Pitt, the username gonna be bradpitt, or bradpitt1, or bradpitt4684, etc...
So my idea is to create an Appwrite Function (Appwrite allows to run backend function) triggered when user is created and inside check if a document with username exist on the
And they create a default username based on the name. Like if the name is Brad Pitt, the username gonna be bradpitt, or bradpitt1, or bradpitt4684, etc...
So my idea is to create an Appwrite Function (Appwrite allows to run backend function) triggered when user is created and inside check if a document with username exist on the
user collection. If true (case : signup with email) return. If false (case: signup OAuth), add document with a username based on the user NameGolden-winged Warbler
might be better or easier to put that in the next-auth callbacks, this is where I update my DB after a successful OAuth
@Golden-winged Warbler might be better or easier to put that in the next-auth callbacks, this is where I update my DB after a successful OAuth
Pacific herringOP
sadly I dont use next-auth for signup and login
Is use Appwrite
NextAuth ive not Appwrite adapter