homanp / langchain-ui

🧬 The open source chat-ai toolkit
https://langchain-ui.vercel.app
MIT License
881 stars 160 forks source link

Authentication #35

Closed bobcave closed 1 year ago

bobcave commented 1 year ago

I encountered an error with the NextAuth.js adapter while attempting to retrieve user information from the database during the OAuth callback handler. The error message indicates that there is an issue with the findUnique method, which is being called on an undefined object. Here's the error message:

[next-auth][error][adapter_error_getUserByAccount] https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read properties of undefined (reading 'findUnique') { message: "Cannot read properties of undefined (reading 'findUnique')", stack: "TypeError: Cannot read properties of undefined (reading 'findUnique')\n" + ' at getUserByAccount (/home/cueva/langchain-ui/node_modules/@next-auth/prisma-adapter/dist/index.js:11:45)\n' + ' ... This issue seems to be caused by an incorrect configuration of the adapter or an issue with the database itself.

Steps to reproduce:

Navigate to the login page Click on the login button and select the OAuth provider Enter the credentials and submit the form Encounter the error message Expected behavior: The user should be able to successfully log in using the OAuth provider.

Actual behavior: Encounter an error with the NextAuth.js adapter when attempting to retrieve user information from the database during the OAuth callback handler.

Environment:

NextAuth.js version: [insert version number here] Operating system: [insert operating system name and version here] Database: [insert database name and version here] Other relevant information: [insert any other relevant information here] Thank you for your help in resolving this issue.

homanp commented 1 year ago

Thanks for reporting!

May I ask What db configuration you have, e.g Prisma config?

homanp commented 1 year ago

@bobcave I just pushed some updates to the migrations. Could you try to purge your db and run the migrations again?

bobcave commented 1 year ago

That solved it!!!! Thanks