Auth.currentAuthenticatedUser returning cached custom attributes instead of current from user store
See original GitHub issueDescribe the bug When registering a user let’s say I set a custom attribute in cognito to A. Later in the registration process I then update it to B. When I call Auth.currentAuthenticatedUser it will still return A. The user needs to logout and log back in to get the latest value.
To Reproduce
- Create a user with a custom attribute and set it to X
- Update it to Y
- Call Auth.currentAuthenticatedUser
- Observe that you still see X even though in the user store it’s updated to Y
Expected behavior I expect the latest/most current attribute value to be returned.
Environment
System:
OS: Linux 5.3 Ubuntu 19.10 (Eoan Ermine)
CPU: (4) x64 Intel(R) Core(TM) i5-6402P CPU @ 2.80GHz
Memory: 1.71 GB / 15.60 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 12.15.0 - /usr/bin/node
npm: 6.13.4 - /usr/bin/npm
Browsers:
Chrome: 80.0.3987.106
Firefox: 73.0.1
npmGlobalPackages:
npm: 6.13.4
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Authentication - Managing user attributes - JavaScript
Authentication. Managing user attributes. In Cognito, you have the ability to manage both standard and custom user attributes for your users.
Read more >Retrieve user's name and email after aws-amplify federated ...
I kinda answered my own question. After authenticating with. Auth.federatedSignIn({provider: 'Google'});. I ran the following code: Auth.
Read more >AWS Cognito & Amplify Auth - Bad, Bugged, Baffling
This would be another easy fix for Cognito. Anyway let's move on. Custom attributes are a MESS #. When you want to store...
Read more >Role-based access control using Amazon Cognito and an ...
An AWS Lambda function named PreTokenGeneration reads the custom:groups custom attribute and converts it to a JSON Web Token (JWT) claim named ...
Read more >Authentication - Test Page
AWS Amplify uses User Pools to store your user information and handle ... SMS messages for Multi-Factor Authentication; Customize attributes for your users, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s a private Repo. I can reference important code pieces though.
Upon signup I’m setting two custom attributes, the second is the important one here:
Upon confirming that the license is correct, I set that custom attribute to “1”. I do this on my backend:
Now back on my frontend if I am to call the Auth.currentAuthenticatedUser() function, it still returns a 0 even though in Cognito I see that it is now a 1.
Only way I’ve found to get the fresh value is by logging out then in again.
I can work around this by making an additional API call myself, but it would be nice if I could get it through the amplify api.
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.