-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Session with all null values on user with jwt, how does it work ? #683
Comments
Hi @Mautriz Thanks for sharing your issue and config! This should actually work out of the box for name, email and picture, as per the example: https://next-auth-example.now.sh/api-example I wonder what the trigger is for this issue. |
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep ot open. Thanks! |
Hi there! It looks like this issue hasn't had any activity for a while. To keep things tidy, I am going to close this issue for now. If you think your issue is still relevant, just leave a comment and I will reopen it. (Read more at #912) Thanks! |
@iaincollins I get the same issue and seems to be related with Prisma adapter. If I remove the adapter, everything works great without callback. |
Here some tests with no user in database (pg) and no user in my Github App. Test 1JWT + Prisma: providers: [
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
secret: process.env.SECRET,
// database: process.env.DATABASE_URL,
adapter: Adapters.Prisma.Adapter({ prisma }),
session: {
jwt: true,
}, Results:
Test 2Session + Prisma // database: process.env.DATABASE_URL,
adapter: Adapters.Prisma.Adapter({ prisma }),
// session: {
// jwt: true,
// }, Result: Success → Session has data. Test 3JWT + Typeorm: database: process.env.DATABASE_URL,
// adapter: Adapters.Prisma.Adapter({ prisma }),
session: {
jwt: true,
}, Result: Success → Session has data. ConclusionSo JWT + Prisma AND |
I found the error. The function getUserByProviderAccountId from the Prisma adapter return a row from the Account table instead of the User table. So here the Is it possible to have a Cc @iaincollins & @balazsorban44. |
in the Prisma adapter, this should fix the issue: - return prisma[Account].findOne({ where: { compoundId: getCompoundId(providerId, providerAccountId) } })
+ const account = await prisma[Account].findOne({ where: { compoundId: getCompoundId(providerId, providerAccountId) } })
+ if (!account) { return null }
+ return prisma[User].findOne({ where: { id: account.userId } }) |
Hi, @ChristoRibeiro could you please create a PR with your recommended fix so it's easier to evaluate? Thank you! |
The issue doesn't appear anymore on the canary branch and the deprecated prisma method |
Yes, hopefully this month. |
Canary has been out for a while now, try it out with |
Are we sure this is working? I am not sure if its just me but I cant seem to get JWT to work with prisma adapter, using canary. |
@lommaj please open a new issue or a discussion with a reproduction of your problem. I would also recommend updating to latest (which is 3.5.1 as of this writing) as. several things have been addressed |
Your question
I'm using JWT, the object return by useSession is always empty (it exists, but with all null values on the user object ex: { name: null, email: null, picture: null } even tho the debug logs everything correctly.
What are you trying to do
I customized the callbacks to return the user, I expected it to this by default, it took me a while to realize how to to it
this is my code
Feedback
Seems like a great library btw ! :D, I probably just misunderstood something I suppose
The text was updated successfully, but these errors were encountered: