nextauthjs / nextauthjs/next-auth
custom session callback dosent return props.user
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Environment
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Memory: 24.44 GB / 31.26 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Browsers:
Chrome: 107.0.5304.110
npmPackages:
next: ^13.0.3 => 13.0.5
next-auth: ^4.17.0 => 4.17.0
react: ^18.2.0 => 18.2.0
Reproduction URL
https://github.com/Swistek92/myApp
Describe the issue
https://next-auth.js.org/tutorials/role-based-login-strategy
said that:
/pages/api/auth/[...nextauth].js
callbacks: {
async session({ session, token, user }) {
session.user.role = user.role; // Add role value to user object so it is passed along with session
return session;
}
},
and in session props dosent include user object
How to reproduce
create next13 app with custom role login system and when i wanna extends session object with role key, following https://next-auth.js.org/tutorials/role-based-login-strategy
there is not a user object into session props from with one i have to copy key
Expected behavior
callbacks: {
async session({session, token, user})
}
but
callbacks: {
async session({session, token})
}
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 linked myApp reproduction and compare its Next.js 13.0.5 and next-auth 4.17.0 configuration with the role-based login tutorial. Trace the session callback inputs and the resulting session props, using the reported credentials-based role flow. Done means the callback behavior is explained and the documented or observed discrepancy is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100