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
For some reason I can't find out, when the user logs in and the record is created in the DB, none of the fields I return in the profile callback are stored.
is it meant to work like that? as a workaround, I'm using signIn to update the db, but feels a little hacky.
Here is my code for auth.ts
exportconstauthOptions: NextAuthOptions={callbacks: {jwt: async({ token, user })=>{console.log("user jwt",user);return{ ...token, ...user};},session: ({ session, user })=>{console.log("user in session (from db)",user,session);return{
...session,user: {
...session.user,id: user.id,name: user.name,},};},asyncsignIn({ user, account, profile }){try{awaitdb.update(users).set({name: profile.name}).where(eq(users.id,user.id));returntrue;// Return true to indicate successful sign-in}catch(error){console.error("Error updating user:",error);returnfalse;// Return false to indicate failed sign-in}},},adapter: DrizzleAdapter(db,{usersTable: users,accountsTable: accounts,sessionsTable: sessions,verificationTokensTable: verificationTokens,})asAdapter,providers: [{/*customproviderfieldsremovedforbrefety*/asyncprofile(profile,tokens){constfields={id: profile.id,name: profile.username,};console.log("fields",fields);returnfields;},},],};
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'm using the T3 stack, with drizzle.
For some reason I can't find out, when the user logs in and the record is created in the DB, none of the fields I return in the profile callback are stored.
is it meant to work like that? as a workaround, I'm using signIn to update the db, but feels a little hacky.
Here is my code for
auth.ts
and here's my schema:
Beta Was this translation helpful? Give feedback.
All reactions