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
So I managed to get data to the session object & JWT token as shown in #2334, but I am not sure how to save this data to the mongoDB database, I need to save additional data such as isBanned as well. I have extended the adapter as shown in the following tutorial: https://next-auth.js.org/tutorials/typeorm-custom-models. But i have had no success:
importAdaptersfrom'next-auth/adapters';// Extend the built-in models using class inheritanceexportdefaultclassUserextendsAdapters.TypeORM.Models.User.model{// You can extend the options in a model but you should not remove the base// properties or change the order of the built-in options on the constructorconstructor(name,email,image,emailVerified){super(name,email,image,emailVerified);}}exportconstUserSchema={name: 'User',target: User,columns: {
...Adapters.TypeORM.Models.User.schema.columns,// Adds a phoneNumber to the User schematest: {type: 'varchar',nullable: true,},},};
providers: [Providers.Discord({clientId: process.env.DISCORD_ID,clientSecret: process.env.DISCORD_SECRET,profile(profile){if(profile.avatar===null){constdefaultAvatarNumber=parseInt(profile.discriminator)%5;profile.image_url=`https://cdn.discordapp.com/embed/avatars/${defaultAvatarNumber}.png`;}else{constformat=profile.avatar.startsWith('a_') ? 'gif' : 'png';profile.image_url=`https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}`;}return{id: profile.id,name: profile.username,image: profile.image_url,email: profile.email,test: 'this is a test of somehting',test1: 'this is another test of something',};},}),],// Database optional. MySQL, Maria DB, Postgres and MongoDB are supported.// https://next-auth.js.org/configuration/databases//// Notes:// You must install an appropriate node_module for your database// The Email provider requires a database OAuth providers do notadapter: Adapters.TypeORM.Adapter(process.env.DATABASE_URL,{models: {User: Models.User,},}),
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.
-
So I managed to get data to the session object & JWT token as shown in #2334, but I am not sure how to save this data to the mongoDB database, I need to save additional data such as isBanned as well. I have extended the adapter as shown in the following tutorial: https://next-auth.js.org/tutorials/typeorm-custom-models. But i have had no success:
Beta Was this translation helpful? Give feedback.
All reactions