nextauthjs / nextauthjs/next-auth
user object is undefined inside signIn callback of auth.js provider
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Environment
OS: Linux 6.4 Fedora Linux 38 (Workstation Edition)
Node: 18.17.0
Brave Browser: 115.1.56.20
Reproduction URL
https://codesandbox.io/p/sandbox/authjs-solidjs-hd4x9n
Describe the issue
In auth.js package the user object received as prop in signIn callback is undefined. This means we can't do custom checks on the user signing up or logging in, or mutate the user object for a client that is signing in for the first time(signing up), for example a populating a required database field with randomly generated value.
How to reproduce
Go to this link:- https://codesandbox.io/p/sandbox/authjs-solidjs-hd4x9n
Do the setup and all that. You will need to populate github client id and secret in .env file. After that click the sign in button and check the console. User object will be undefined.
Expected behavior
Go to this link:- https://codesandbox.io/p/sandbox/next-auth-nextjs-kwkj6s
Same thing as above but this time user object is logged normally and it isn't undefined.
So ultimately the next-auth package works while auth.js package doesn't.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the auth.js SolidJS reproduction at https://codesandbox.io/p/sandbox/authjs-solidjs-hd4x9n and compare its signIn callback behavior with the working Next.js example at https://codesandbox.io/p/sandbox/next-auth-nextjs-kwkj6s. Configure the GitHub client credentials, sign in, and inspect the console; done means the callback receives the user object as it does in the working example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100