-
Hi! I'm using Auth.js with Prisma and I have extended the User model to include some many to many. I'm using database strategy and now I'm trying to include those many to many fields on my session callback so it generates the session with the additional info, but no luck yet. I'm testing including the "status" field which is a basic enum and it works like a charm to extend the session, but for many to many relationships I'm not able to resolve the query to bring the respective data. Any tip? Prisma Model: model User { Session Callback:
} Module Augumentation (next-auth.d.ts): import { type Organization } from "@prisma/client"; declare module "next-auth" { interface Session extends DefaultSession { Console return for the session callback: Augumented Session { Is this possible? What would be the correct way to handle this situation with Authjs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For anybody trying to achieve the same, I was able to make it work by extending the PrismaAdapter overriding the getSessionAndUser method with another prisma query that include the organization array as part of it. ![]() |
Beta Was this translation helpful? Give feedback.
For anybody trying to achieve the same, I was able to make it work by extending the PrismaAdapter overriding the getSessionAndUser method with another prisma query that include the organization array as part of it.
Took me 3 days to figure out, maybe some docs improvements on that would be good. The starting point to discover this was debugging the adapter queries and the Adapter docs helped me as well