Closed daviddalmaso closed 2 years ago
Hi I was able to repro this. Access and Id tokens are stateless and are valid until they are expired and the library on the client will use it until expires to try to get new ones. Could you change the code to this instead?
Auth.currentAuthenticatedUser({
bypassCache: true
})
Here is the documentation link, https://docs.amplify.aws/lib/auth/manageusers/q/platform/js/#retrieve-current-authenticated-user
This seemed to have solved my issue. Simple fix, sorry, that I had tried that.
Why is it though that setting bypassCache
to false doesn't create this issue for a separate authenticationFlowType
?
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 amplify-help
forum.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth, function, api
Environment information
Describe the bug
When my app first opens, I check for an authenticated user using the following code block.
I have recently switched to using CUSTOM_AUTH for my authenticationFlowType. Previously I was able to delete users through the Cognito console and this would change the behavior of the function above such that no user is returned (and I would redirect the user to a sign up / login screen).
However, when using the CUSTOM_AUTH authenticationFlowType, I have not had this behavior. Instead, after deleting the user from the Cognito console, that user still pops up as the currentAuthenticatedUser.
Expected behavior
I am expecting the
Auth.currentAuthenticatedUser()
to not return aCognitoUser
object if that user has been deleted from Cognito.Reproduction steps
aws-amplify
with a react-native projectamplify add auth
a. Set up the auth to use phone number as the sign in method b. Set up a custom authentication flow with customDefineAuthChallenge
,CreateAuthChallenge
,VerifyAuthChallenge
, andPreSignUp
lambda triggers. Implementations of these lambdas can be found from this tutorial.App.js
file to check forcurrentAuthenticatedUser
authenticationFlowType
toCUSTOM_AUTH
to the top of yourApp.js
Amplify.configure(awsconfig) Auth.configure({ authenticationFlowType: 'CUSTOM_AUTH' })
Log output
aws-exports.js
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