Closed bertrand-caron closed 6 months ago
Hey @bertrand-caron 👋 where are you calling Auth.signOut
? Are you trying to log the user out if they leave the app and expect them to be logged out when the app restarts? Or are you calling currentAuthenticatedUser
afterwards to verify they're logged out?
Just trying to get a better understanding of what we're trying to achieve by calling Auth.signOut
before Auth.currentAuthenticatedUser
. Seeing how and at what point each method is being called will help.
Hey @chrisbonifacio, thanks for looking into this.
I'm calling Auth.signOut()
before any calls to Auth. currentAuthenticatedUser()
. It just seemed very counter-intuitive to me that Auth. currentAuthenticatedUser()
would succeed, but Auth.signOut()
did not (unless I had called Auth. currentAuthenticatedUser()
before).
Does that make sense?
Maybe this does not warrant any code change, but at least documentation update to Auth.signOut()
to make it explicit? I spent much longer than I'd like to admit understanding what was happening.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
Hi :wave: Sorry this was auto-closed by stale bot. We are working towards preventing this from happening in the future. Please let us know if you are still experiencing this issue and in need of assistance.
I think I experienced the same bug on React web-app right now with: "aws-amplify-react": "^5.0.13" / "@aws-amplify/ui-react": "^1.2.14",
My scenario:
So does singOut() actually not singout the user? It just removes the local storage/session information of the authenticated session only?
@bertrand-caron, I was able to reproduce this reliably and created this sample repo for further investigation. For anyone wanting to reproduce, the following order of events has to occur:
Auth.signOut()
)Auth.currentAuthenticatedUser()
)@bertrand-caron, this should now be resolved with the release of v6 of Amplify. The Auth API's have changed and the equivalent to Auth.currentAuthenticatedUser()
would be the v6 getCurrentUser API. Are you able to upgrade and test this to confirm it on your side as well? When testing this locally on v6, I'm not seeing the issue anymore.
@bertrand-caron This should be solved in the latest version of Amplify V5. You may update the aws-amplify
version to 5.3.18
and see if it resolves the issue on your React Native app. Thank you.
With this now fixed in v5 (as of v5.3.18) and not an issue in v6, we'll close this.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Calling
Auth.SignOut()
before any call toAuth.currentAuthenticatedUser()
does not log the user out onreact-native
application restart. I don't think thereact-native
part is relevant but am including it just in case.Expected behavior
Calling
Auth.SignOut()
will log the user out ifAuth.currentAuthenticatedUser()
would have returned a non-null value.Reproduction steps
react-native
app that uses@aws-amplify/auth
Auth.signIn()
Auth.signOut()
-> This will not log the user out.Auth.currentAuthenticatedUser()
thenAuth.signOut()
-> This will log the user out.Code Snippet
Log output
aws-exports.js
No response
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