Fix update trigger in nextauth

This commit is contained in:
austinkelsay 2024-10-09 16:28:24 -05:00
parent fc6f1ce11f
commit 702db8de56

View File

@ -169,7 +169,13 @@ export const authOptions = {
}),
],
callbacks: {
async jwt({ token, user, account }) { // Add 'account' parameter here
async jwt({ token, user, account, trigger }) {
if (trigger === "update" && account?.provider !== "anonymous") {
// if we trigger an update call the authorize function again
const newUser = await authorize(token.user.pubkey);
token.user = newUser;
}
if (user) {
token.user = user;
if (user.pubkey && user.privkey) {