Replies: 2 comments
-
I have been forced to do this using A wrapper around // Session Cb
async session({ session, token }) {
session.user.content = superjson.stringify(
await prisma.user.findUniqueOrThrow({ where: { id: token.sub } }),
);
return session;
},
},
// Wrapper
const auth = cache(async () => {
const session = await defaultAuth();
return session
? {
expires: session.expires,
user: superjson.parse<SessionUser>(session.user.content),
}
: null;
}); Note Therefore I'm still not sure if it's the correct place to fetch user. Doc doesn't shows anything. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@balazsorban44 Important issue I think |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
hi @balazsorban44 @ThangHuuVu
I'm using
session
callback in auth.ts with prisma ORMAs prisma returns Date instance for DateTime type, they get passed to session.user
If you display session.user.createdAt inside the session callback, you get an object.
elsewhere
auth()
returns a string. (because of serialization).Is that an expected behavior ? Even of server component ?
Therefore my typing get wrong. And i can have very strange issues, where you are supposing having a date object and you have a string that cause bad behavior silently.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions