-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next-auth v5 - logging in using (oauth provider) with prisma adapter & mongdb #9685
Comments
Hey, I was going through your repo and it seems like there is an issue with the createUser method inside of the PrismaAdapter. What I did to solve it is spread the inside of your auth.ts do this install the bson-objectid and import it
update your adapter to look like this
That should fix the issue. Hope this helps! |
Thank you so much sir |
My Pleasure! |
Good day sir, I have another problem with deploying in vercel |
Hey, you can do this for now adapter: {
...PrismaAdapter(db),
createUser(user) {
return db.user.create({
data: {
...user,
id: ObjectId().toHexString()
}
}) as any
} You actually don't have to add async to the create user as it returns the promise. Just to let you know your not exporting update from You should install Also keep running Let me know if you have other questions. Take care. |
Still have this type error sir |
I moved the "as any" in the end of bracket of "data: {} as any" then the error is gone |
That's strange the type error disappeared on my side after adding as any to the end of the createUser method that had the type error. Great to hear its good now 😄. Are you able to deploy it? |
Yes thank you so much 😊 |
Awesome, my pleasure! |
Woah, this fix helps me too, thanks! It's because they try to store the id from the oauth provider, just opened #9699 |
@meruiden Great to hear it helped and thanks for opening the issue. |
also solves my issue ❤️ |
import NextAuth from "next-auth"; declare module "next-auth" { import authConfig from "./auth.config"; export const {
}, Type 'import("e:/Users/abdurahman a.mohamed/Desktop/next/mad/node_modules/@auth/core/adapters").Adapter' is not assignable to type 'import("e:/Users/abdurahman a.mohamed/Desktop/next/mad/node_modules/next-auth/node_modules/@auth/core/adapters").Adapter'. |
Thank you so much!!! was struggling for a long time to fix this issue!!!! |
Environment
System:
OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (12) x64 AMD Ryzen 5 4600G with Radeon Graphics
Memory: 275.91 MB / 3.48 GB
Container: Yes
Shell: 3.6.1 - /home/linuxbrew/.linuxbrew/bin/fish
Binaries:
Node: 21.3.0 - /home/linuxbrew/.linuxbrew/bin/node
npm: 10.2.4 - /home/linuxbrew/.linuxbrew/bin/npm
pnpm: 8.14.0 - ~/.local/share/pnpm/pnpm
bun: 1.0.23 - ~/.bun/bin/bun
npmPackages:
@auth/prisma-adapter: ^1.0.14 => 1.0.15
next: latest => 14.1.0
next-auth: beta => 5.0.0-beta.5
react: ^18 => 18.2.0
Reproduction URL
https://github.com/igmtink/igmt-auth
Describe the issue
Whenever I logging in using
oauth provider
which isgoogle provider
I've got this error:How to reproduce
Sign in with
Google
Expected behavior
Create the user in my mongodb after logging in with google provider, and successfully sign in.
The text was updated successfully, but these errors were encountered: