You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add new properties in the users collection in the database. What is the best way to do it.
This is what i'm trying to accomplish :
On signIn page,user enter email -> user receive email and validate -> user is created with role "user" -> user is redirected to complete profile page -> save in database in users collection(name,adress ect...) -> get the data avaible in useSession hook.
I have tried to use this solution to add roles and it works, but i feel its not the purpose of events : #859
import{MongoClient}from'mongodb';
createUser: async(message)=>{constclient=newMongoClient(process.env.DATABASE_URL,{useNewUrlParser: true,useUnifiedTopology: true,});if(!client.isConnected())awaitclient.connect();constdbName=process.env.DATABASE_URL.split('/').pop().split('?').shift();letusersCollection=client.db(dbName).collection('users');usersCollection.updateOne({_id: message.id},{$set: {myCustomData: 'can I add this to db when user login first time? '},});}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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 am trying to add new properties in the users collection in the database. What is the best way to do it.
This is what i'm trying to accomplish :
On signIn page,user enter email -> user receive email and validate -> user is created with role "user" -> user is redirected to complete profile page -> save in database in users collection(name,adress ect...) -> get the data avaible in useSession hook.
So i'm trying to custom the users model like in the documentation but it is not working.
https://next-auth.js.org/tutorials/typeorm-custom-models
I have also tried like in this discussion without success.
#805
Here is my code :
I have tried to use this solution to add roles and it works, but i feel its not the purpose of events :
#859
Thank you for your help
Beta Was this translation helpful? Give feedback.
All reactions