Potential bug: Calling signOut() before currentAuthenticatedUser() does not log the user out on react-native app restart
See original GitHub issueBefore opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
# Put output below this line
System:
OS: macOS 11.4
CPU: (8) arm64 Apple M1
Memory: 95.45 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Chrome: 91.0.4472.77
Firefox: 88.0.1
Safari: 14.1.1
npmPackages:
@aws-amplify/api: 4.0.1 => 4.0.1
@aws-amplify/auth: 4.0.1 => 4.0.1
@aws-amplify/core: 4.0.1 => 4.0.1 (4.0.3)
@babel/core: ^7.8.4 => 7.12.16 (7.14.3)
@babel/runtime: ^7.8.4 => 7.12.13 (7.14.0)
@fortawesome/fontawesome-svg-core: ^1.2.35 => 1.2.35
@fortawesome/free-regular-svg-icons: ^5.15.3 => 5.15.3
@fortawesome/free-solid-svg-icons: ^5.15.3 => 5.15.3
@fortawesome/react-native-fontawesome: ^0.2.6 => 0.2.6
@onfido/react-native-sdk: ^1.3.4 => 1.3.4
@react-native-async-storage/async-storage: ^1.14.1 => 1.14.1
@react-native-community/datetimepicker: ^3.4.2 => 3.4.2
@react-native-community/eslint-config: ^1.1.0 => 1.1.0
@react-native-community/netinfo: ^5.9.10 => 5.9.10
@react-native-community/progress-bar-android: ^1.0.4 => 1.0.4
@react-native-community/progress-view: ^1.2.4 => 1.2.4
@sentry/react-native: ^2.3.0 => 2.4.0
@types/amplitude-js: ^7.0.1 => 7.0.1
@types/jest: ^25.2.3 => 25.2.3
@types/react-native: ^0.63.2 => 0.63.49 (0.64.2)
@types/react-native-vector-icons: ^6.4.6 => 6.4.6
@types/react-test-renderer: ^16.9.2 => 16.9.5
@typescript-eslint/eslint-plugin: ^4.15.0 => 4.15.0 (2.34.0)
HelloWorld: 0.0.1
PDFExample: 0.0.1
amazon-cognito-identity-js: ^4.5.11 => 4.5.11 (5.0.2)
amplitude-js: ^7.4.2 => 7.4.2
babel-jest: ^25.1.0 => 25.5.1
date-fns: ^2.21.3 => 2.21.3
docs: 0.0.0
eslint: ^7.20.0 => 7.20.0
eslint-config-airbnb-typescript: ^12.3.1 => 12.3.1
eslint-config-prettier: ^7.2.0 => 7.2.0 (6.15.0)
eslint-plugin-import: ^2.22.1 => 2.22.1
eslint-plugin-jsx-a11y: ^6.4.1 => 6.4.1
eslint-plugin-react: ^7.22.0 => 7.22.0 (7.19.0)
example: 0.1.0
fbjs: ^3.0.0 => 3.0.0
hermes-inspector-msggen: 1.0.0
jest: ^25.1.0 => 25.5.4
memo-parser: 0.2.1
metro-react-native-babel-preset: ^0.59.0 => 0.59.0 (0.64.0)
prettier: ^2.2.1 => 2.2.1
react: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1
react-native-biometrics: ^2.1.4 => 2.1.4
react-native-chart-kit: ^6.11.0 => 6.11.0
react-native-device-info: ^8.0.1 => 8.0.1
react-native-navigation: 7.15.0 => 7.15.0
react-native-navigation-bar-color: ^2.0.1 => 2.0.1
react-native-pdf: ^6.3.0 => 6.3.0
react-native-smooth-pincode-input: ^1.0.9 => 1.0.9
react-native-svg: ^12.1.0 => 12.1.0
react-native-toast-message: ^1.4.9 => 1.4.9
react-native-vector-icons: ^8.1.0 => 8.1.0
react-redux: ^7.2.4 => 7.2.4
react-test-renderer: 16.13.1 => 16.13.1
redux: ^4.1.0 => 4.1.0
redux-persist: ^6.0.0 => 6.0.0
redux-persist/integration/react: undefined ()
rn-fetch-blob: ^0.12.0 => 0.12.0
typescript: ^3.8.3 => 3.9.9
npmGlobalPackages:
npm: 6.14.11
yarn: 1.22.10
Describe the bug
Calling Auth.SignOut()
before any call to Auth.currentAuthenticatedUser()
does not log the user out on react-native
application restart.
I don’t think the react-native
part is relevant but am including it just in case.
Expected behavior
Calling Auth.SignOut()
will log the user out if Auth.currentAuthenticatedUser()
would have returned a non-null value.
Reproduction steps
- Write
react-native
app that uses@aws-amplify/auth
- Log in using
Auth.signIn()
- Restart App
- Call
Auth.signOut()
-> This will not log the user out. - Call
Auth.currentAuthenticatedUser()
thenAuth.signOut()
-> This will log the user out.
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Amplify Hub.listen immediately calls signOut after signIn when ...
I'm having an issue implementing SSO with AWS Amplify into my React Native app. I have SSO working fine, however, when trying to...
Read more >Authentication - Social sign-in (OAuth) - React Native
OAuth 2.0 is the common Authorization framework used by web and mobile applications for getting access to user information ("scopes") in a limited...
Read more >Tutorial: Create a React single-page app that uses auth code ...
In this tutorial, you create a React SPA that can sign in users and use ... and sign-out; Add code to call Microsoft...
Read more >AWS Amplify Authentication in React Native (Full tutorial)
Learn how to integrate a custom authentication UI in React Native with AWS Amplify Authentication. The tutorial will walk you through the ...
Read more >The Complete React Native Guide to User Authentication with ...
An in depth guide for adding authentication to your next mobile app using React Native and AWS Amplify. Tagged with aws, reactnative, ...
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
Hey @chrisbonifacio, thanks for looking into this.
I’m calling
Auth.signOut()
before any calls toAuth. currentAuthenticatedUser()
. It just seemed very counter-intuitive to me thatAuth. currentAuthenticatedUser()
would succeed, butAuth.signOut()
did not (unless I had calledAuth. 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.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?