Feature req: Set session.user.id
automatically when using a database adapter
#8911
jasongitmail
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I agree. I've written a variant, as I have been switching between database and jwt strategies: session({ session, token, user }) {
if (session?.user) {
// @ts-expect-error Property id does not exist
session.user.id = user?.id || token?.sub;
}
return session
} |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Automatically make
session.user.id
available on the session when a database adapter exists in the config, irrespective of whether using adatabase
orjwt
session strategy. It should contain theid
from theuser
database table.Non-Goals
No response
Background
Currently you have to add this manually, like this for a database session:
but then this also breaks if changing to a session.strategy of
jwt
.Proposal
This is so common, it should be default to create a better developer experience, for both sessions stored in the database or jwt, so long as a database adapter exists.
Beta Was this translation helpful? Give feedback.
All reactions