From 20b18d8cfdf4497254f86142ced377b619d0fa38 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 30 Jan 2024 12:45:21 +0700 Subject: [PATCH] Cleanup comments in AuthProvider --- packages/auth/src/AuthProvider/AuthProvider.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/auth/src/AuthProvider/AuthProvider.tsx b/packages/auth/src/AuthProvider/AuthProvider.tsx index 97afe439b235..9433d2f58cfc 100644 --- a/packages/auth/src/AuthProvider/AuthProvider.tsx +++ b/packages/auth/src/AuthProvider/AuthProvider.tsx @@ -133,17 +133,11 @@ export function createAuthProvider< // Whenever the authImplementation is ready to go, restore auth and reauthenticate useEffect(() => { async function doRestoreState() { - // @MARK: this is where we fetch currentUser from graphql again - // because without SSR, initial state doesn't exist - // what we want to do here is to conditionally call reauthenticate - // so that the restoreAuthState comes from the injected state - - // the problem is that reauthenticate does both getCurrentUser and udpate the auth state await authImplementation.restoreAuthState?.() - // If the inital state didn't come from the server (or was restored before) - // reauthenticate will make an API call to the middleware to receive the current user - // (instead of called the graphql endpoint with currentUser) + // @MARK(SSR-Auth): Conditionally call reauth, because initial state should come from server (on SSR) + // If the inital state didn't come from the server - or was restored already - + // reauthenticate will make an call to receive the current user from the server if (!serverAuthState) { reauthenticate() }