File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/libs/next-auth/adapter Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -68,23 +68,26 @@ export function LobeNextAuthDbAdapter(serverDB: NeonDatabase<typeof schema>): Ad
6868 }
6969
7070 // create a new user if it does not exist
71+ // Use id from provider if it exists, otherwise use id assigned by next-auth
72+ // ref: https://github.com/lobehub/lobe-chat/pull/2935
73+ const uid = providerAccountId ?? id ;
7174 await UserModel . createUser (
7275 serverDB ,
7376 mapAdapterUserToLobeUser ( {
7477 email,
7578 emailVerified,
7679 // Use providerAccountId as userid to identify if the user exists in a SSO provider
77- id : providerAccountId ?? id ,
80+ id : uid ,
7881 image,
7982 name,
8083 } ) ,
8184 ) ;
8285
8386 // 3. Create an inbox session for the user
84- const agentService = new AgentService ( serverDB , id ) ;
87+ const agentService = new AgentService ( serverDB , uid ) ;
8588 await agentService . createInbox ( ) ;
8689
87- return { ...user , id : providerAccountId ?? id } ;
90+ return { ...user , id : uid } ;
8891 } ,
8992 async createVerificationToken ( data ) : Promise < VerificationToken | null | undefined > {
9093 return serverDB
You can’t perform that action at this time.
0 commit comments