fix: fetch user profile via GraphQL in authStore #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what
Fixes the issue where
userProfileinauthStoreis not populated after authentication, causing downstream apps (e.g.,agents-ui) to display "Guest" instead of the authenticated user's namewhy
the
authStoredid not fetch the user profile data (username, email, etc.) after setting theaccessToken, nor did it initialize its state usingdynamic_authentication_tokenfromLocal Storage. This led touserProfilebeingundefined, affecting apps that rely onuseAuthStoreto provide user datahow
authStore.tsto:accessToken,projectId, andisLoggedInusingdynamic_authentication_tokenfromLocal Storageon store creationMequery) after settingaccessToken, retrievinguserId,username,email, andavatarfrom the MySQL database.userProfilewith the fetched data.setAccessTokenasync and updatedupdateAccessTokenByProjectIdto await ittesting
Local Storagedata fromagents-ui, which showsdynamic_authentication_tokenwith a valid email ("g4titan1@gmail.com")userProfileis populated with the correct username (e.g., "g4titan1")we might consider adding retry logic or a fallback for GraphQL fetch failures if needed