From a776faf4dfb513307ff403c6e58df0c869be661d Mon Sep 17 00:00:00 2001 From: Koen Poelhekke Date: Thu, 3 Oct 2024 10:14:03 +0200 Subject: [PATCH] fix: allow updating session in SessionProvider when logged out and no session is set --- packages/next-auth/src/react.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/next-auth/src/react.tsx b/packages/next-auth/src/react.tsx index e23e3609e0..d333b4105d 100644 --- a/packages/next-auth/src/react.tsx +++ b/packages/next-auth/src/react.tsx @@ -501,13 +501,11 @@ export function SessionProvider(props: SessionProviderProps) { : { body: { csrfToken: await getCsrfToken(), data } } ) setLoading(false) - if (newSession) { - setSession(newSession) - broadcast().postMessage({ - event: "session", - data: { trigger: "getSession" }, - }) - } + setSession(newSession) + broadcast().postMessage({ + event: "session", + data: { trigger: "getSession" }, + }) return newSession }, }),