Skip to content
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

[Bug] Prisma 2 adapter return wrong User model on "getUserByProviderAccountId" #559

Closed
sondh0127 opened this issue Aug 7, 2020 · 9 comments · Fixed by #626
Closed

[Bug] Prisma 2 adapter return wrong User model on "getUserByProviderAccountId" #559

sondh0127 opened this issue Aug 7, 2020 · 9 comments · Fixed by #626
Labels
bug Something isn't working priority Priority fix or enhancement

Comments

@sondh0127
Copy link

return prisma[Account].findOne({ where: { compoundId: getCompoundId(providerId, providerAccountId) } })

It should return User model instead of Account like the TypeOrm adapter did

return manager.findOne(User, { [idKey]: account.userId })

@iaincollins iaincollins added the bug Something isn't working label Aug 13, 2020
@iaincollins
Copy link
Member

Sorry for the delay in responding to this (it's been a busy week!)

Thanks for reporting this bug.

@lovettbarron
Copy link

lovettbarron commented Sep 3, 2020

Grateful that this was found.
I think I'm getting the same error where the session's userId is referencing the AccountID instead of the User id.

[next-auth][debug][prisma_update_session] {
  id: 19, // Session id
  userId: 3, // Maps to account id
  expires: 2020-12-02T21:24:40.349Z,
  sessionToken: sdfsdfsdf
  accessToken: asdfsdfsdf
  createdAt: 2020-09-03T21:24:40.350Z,
  updatedAt: 2020-09-03T21:24:40.350Z
}

[next-auth][error][session_error] TypeError: Cannot read property 'name' of null
    at /node_modules/next-auth/dist/server/routes/session.js:99:26

@iaincollins
Copy link
Member

@readywater As a quick up date, we've merged in a fix, but it's not live yet - it will go out with some other fixes in the next release (I hope in the next few days)!

@lovettbarron
Copy link

Now that I know what it is, I've just updated the Session entry with the appropriate userid so I can do the work. Looking forward to the fix and thank you for this awesome library. I'm actually testing it out for a larger existing application and really love what I see.

@lovettbarron
Copy link

Hi @iaincollins, quick question: is there an easy way to pull a beta release of this fix into NPM? Or would you suggest just forking + building? Again, grateful for the work you guys are doing on this!

@madx
Copy link

madx commented Oct 23, 2020

Hi @iaincollins , any news about the availability of this fix? I've been bitten by the bug as well: getting a session upon signup works but once I try to sign in again it can't find the user since I switched user IDs to cuids (which is otherwise working fine by the way)

@lovettbarron
Copy link

Hi @iaincollins , any news about the availability of this fix? I've been bitten by the bug as well: getting a session upon signup works but once I try to sign in again it can't find the user since I switched user IDs to cuids (which is otherwise working fine by the way)

FYI i ended up forking and just importing that into NPM.
Just take a look at the commits to package, etc for the changes you'll need to make.
https://github.com/stupidsystems/next-auth/

@madx
Copy link

madx commented Oct 23, 2020

FYI i ended up forking and just importing that into NPM.
Just take a look at the commits to package, etc for the changes you'll need to make.
https://github.com/stupidsystems/next-auth/

Thanks for your input, since the bug seems to reside mostly in the Prisma adapter I think I'm just gonna create a custom fork of the adapter to void having to maintain my own.

@github-actions
Copy link

github-actions bot commented Feb 1, 2021

🎉 This issue has been resolved in version 3.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Priority fix or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants