From 9b154e9002e51ba9f96aa4bccd14338ee2aec3c0 Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Mon, 4 Sep 2023 18:47:05 +0100 Subject: [PATCH] fix: note about sub from oauth --- pages/api/auth/[...nextauth].js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 1a1b57a0552..1228d39b756 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -65,8 +65,9 @@ export const authOptions = { async session({ session, token }) { await connectMongo(); // Send properties to the client, like an access_token and user id from a provider. + // note: `sub` is the user id session.accessToken = token.accessToken; - session.user.id = token.id; + session.user.id = token.sub; session.username = token.username; const user = await User.findOne({ _id: token.sub }); if (user) {