question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auth.currentAuthenticatedUser should return error if user is signed out globally from backend (may be with aws cli).

See original GitHub issue

Describe the bug Auth.currentAuthenticatedUser returns CognitoUser evenif the access token for the user is invalidated from backend (i.e. signed out globally with aws cli which invalidated all the tokens including refresh token: https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/global-sign-out.html)

To Reproduce Steps to reproduce the behavior: 0. Have react application having basic functionality for signin/ signout/ home page etc…

  1. Signin using amplify sign in api
  2. U have the access, id, refresh token in ur configured storage.
  3. on componentDidMount call
Auth.currentAuthenticatedUser()
        .then((session) => {
            console.log("In then block");
               
        })
        .catch((error) => {
            console.log("In catch block")
            this.setState({validSession: false});
        })   
  1. get the access token from you configured storage use aws cli to signout globally. this will invalidate all your token.
  2. Refresh the page

Expected behavior Actually we want to automatically sign out the user from the application. so we are checking Auth.currentAuthenticatedUser() should return error but it still returns CognitoUser object.

Is there any other way to automatically signout in such case?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
manueliglesiascommented, Jan 31, 2019

Hi @mmritesh

Can you try using

Auth.currentAuthenticatedUser({bypassCache: true})
0reactions
github-actions[bot]commented, Jun 11, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

update-backend-auth — AWS CLI 1.27.32 Command Reference
Defines the service name to use when configuring an authentication resource in your Amplify project. UserPoolConfigs -> (structure). Describes the ...
Read more >
How to Setup Authentication Fast with AWS Amplify
currentAuthenticatedUser () method to check if the user has been authenticated. If yes, it returns the user object. signOut - This function uses ......
Read more >
Full Stack Cloud Development with AWS Amplify
This is done by calling the currentAuthenticatedUser method of the Auth class from Amplify. If there's a signed in user, this function returns...
Read more >
Advanced workflows - Lambda Triggers - AWS Amplify Docs
The CLI Auth workflow provides the following Lambda trigger templates: ... that is returned when the user interacts with the Google reCaptcha component....
Read more >
AWS Amplify, how to check if user is logged in? - Stack Overflow
I'm using the ionViewCanEnter() function in every page to allow/deny access. The return value of this function determines if the page can be ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found