How to ensure the User ID is the same as the Provider Account ID? #12318
Unanswered
tobiasbueschel
asked this question in
Help
Replies: 0 comments
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.
-
Hi team,
Thanks to all of you for building Auth.js - it's a fantastic library and simplifies IAM work a lot 👏
Context
I'm integrating Auth.js into a Next.js application that will only ever connect to a single identity provider via OIDC using the JWT-based session strategy.
sub
of the user's JWT) into aUser
table in my databaseAccount
table as aUser
table already suffices for my use caseThe problem I ran into
However, at the moment, there seems to be no way to ensure the
user.id
is exactly the same as theproviderAccountId
or in other words the same as the JWTsub
created by the provider as it's being overwritten here:next-auth/packages/core/src/lib/actions/callback/oauth/callback.ts
Lines 305 to 313 in 3ec0684
I've found a workaround by pulling the correct value from e.g.,
profile.sub
ortoken.sub
, but I wonder whether there is a better way to implement my use case, or if this something that could/should be natively supported in Auth.js? (e.g., it would be nice to use Database adapters without having to use the Database Session strategy and having the adapter directly make the update in the correct DB table without having to callcreateUserIfNotExists
manually)Beta Was this translation helpful? Give feedback.
All reactions