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

fix(types): Session callback params does not include user and token #9646

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,13 @@ export interface CallbacksOptions<P = Profile, A = Account> {
* @see [`jwt` callback](https://authjs.dev/reference/core/types#jwt)
*/
session: (
params: (
| {
session: Session
/** Available when {@link AuthConfig.session} is set to `strategy: "database"`. */
user: AdapterUser
}
| {
session: Session
/** Available when {@link AuthConfig.session} is set to `strategy: "jwt"` */
token: JWT
}
) & {
params: {
session: Session
/** Available when {@link AuthConfig.session} is set to `strategy: "database"`. */
user?: AdapterUser
/** Available when {@link AuthConfig.session} is set to `strategy: "jwt"` */
token?: JWT
} & {
/**
* Available when using {@link AuthConfig.session} `strategy: "database"` and an update is triggered for the session.
*
Expand Down
1 change: 0 additions & 1 deletion packages/next-auth/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async function getSession(headers: Headers, config: NextAuthConfig) {
const session =
// If the user defined a custom session callback, use that instead
(await config.callbacks?.session?.(...args)) ?? args[0].session
// @ts-expect-error either user or token will be defined
const user = args[0].user ?? args[0].token
return { user, ...session } satisfies Session
},
Expand Down
Loading