Closed GM1957 closed 3 years ago
Hi @GM1957,
I think the reason you are seeing old information on the second call to Auth.currentAuthenticatedUser
is because the first call to get the current user is cached. To get the latest data from Cognito, you will need to call Auth.currentAuthenticatedUser
with params to bypass the cache.
API references: https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser
Example:
// first call:
const cognitoUser = await Auth.currentAuthenticatedUser();
// call Cognito backend API to update the user info (added one more attribute "profile": 1)
// second call specifying that cache should be bypassed:
const updatedCognitoUser = await Auth.currentAuthenticatedUser({ bypassCache: true }) // should return user with "profile" update
Please let me know if this solves the problem.
Yeah @reesscot I got the solution later. Thanks for your reply
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Unable to get current attributes and their values from Cognito
Here is the complete flow of what I did
Expected behavior
after updating user attributes in the Cognito ( like i added a new attribute profile )
from this log
we should get the details of the updated attribute but got old details, after doing signout and again login this log gave the correct result
Reproduction steps
Code Snippet
Log output
aws-exports.js
const appConfig = {
};
// You can get the current config object export default appConfig
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response