From 702db8de56c76042d62525654fb676092dd11972 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Wed, 9 Oct 2024 16:28:24 -0500 Subject: [PATCH] Fix update trigger in nextauth --- src/pages/api/auth/[...nextauth].js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js index 0315638..d055771 100644 --- a/src/pages/api/auth/[...nextauth].js +++ b/src/pages/api/auth/[...nextauth].js @@ -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) {