-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
bugSomething isn't workingSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Description
x^### Environment
System:
OS: macOS 15.2
CPU: (8) arm64 Apple M1 Pro
Memory: 93.78 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /opt/homebrew/opt/node@22/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.2 - /opt/homebrew/opt/node@22/bin/npm
bun: 1.2.10 - /opt/homebrew/bin/bun
Browsers:
Chrome: 135.0.7049.114
Safari: 18.2
npmPackages:
@auth/prisma-adapter: ^2.9.0 => 2.9.0
next: 15.3.1 => 15.3.1
next-auth: ^5.0.0-beta.26 => 5.0.0-beta.26
react: ^19.1.0 => 19.1.0
Reproduction URL
https://github.com/rhufsky/authdemo
Describe the issue
Cannot update JWT after initial creation at login time, shown by a simplified example. In the current state, it seems that I am unable to implement token refresh as described in https://authjs.dev/guides/refresh-token-rotation.
How to reproduce
Login and watch the jwt()
callback. As a sample I create an arbitrary property status
and set it to "INITIAL"
at the first invocation of jwt()
.
When jwt()
is invoked for a second time, it returns a token with status: "REFRESH"
.
The new value is never persisted, at the third invocation of jwt()
, status
is still "INITIAL"
.
async jwt({ token, user, account, profile }) {
console.log(token);
if (account && profile && user) {
console.log("INITIAL JWT");
return {
...token,
status: "INITIAL",
};
} else {
console.log("SUBSQUENT JWT");
return { ...token, status: "REFRESH" };
}
},
Expected behavior
After every invocation of jwt()
the returned token should be persisted.
cm-santos, anonimoxdver, rubenqba, emilycanas, ardenc and 18 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.