Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify.Auth.confirmSignIn() does nothing after SignIn session expires #2129

Closed
1 task done
sayamimi opened this issue Nov 21, 2022 · 4 comments · Fixed by #2187
Closed
1 task done

Amplify.Auth.confirmSignIn() does nothing after SignIn session expires #2129

sayamimi opened this issue Nov 21, 2022 · 4 comments · Fixed by #2187
Assignees
Labels
auth Related to the Auth category/plugins bug Something isn't working

Comments

@sayamimi
Copy link

Before opening, please confirm:

Language and Async Model

Kotlin - Coroutines

Amplify Categories

Authentication

Gradle script dependencies

implementation "com.amplifyframework:core-kotlin:2.0.0"
implementation "com.amplifyframework:aws-auth-cognito:2.0.0"

Environment information

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.13 (JetBrains s.r.o. 11.0.13+0-b1751.21-8125866)
OS:           Windows 10 10.0 amd64



Please include any relevant guides or documentation you're referencing

No response

Describe the bug

My project only uses some simple features of Cognito. The user has a temporary password, so they just use it to sign in and then register their real password.
In code,
Amplify.Auth.signIn(ID, temporary password), and if nextStep.signInStep is "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD", Amplify.Auth.confirmSignIn(new Password).

If you call Amplify.Auth.confirmSignIn() within a few minutes of calling Amplify.Auth.signIn(), the session has not expired and will succeed.
After 5 minutes or so and the session expires, Amplify.Auth.confirmSignIn() throws an error NotAuthorizedException. Up to this point, it is the same as the previous ver 0.21.6.
However, from the new ver2.0.0, even if you call Amplify.Auth.signIn(ID, temporary password) again, without taskkilling the app, the error InvalidStateException below will occur. I signed in again successfully with the old ver 0.21.6.
How can I successfully confirmSignIn or SignIn, other than taskkilling?

Reproduction steps (if applicable)

  1. Call Amplify.Auth.signIn(ID, temporary password).
  2. If nextStep.signInStep is "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD", please wait 3~5 min of default time.
  3. Call Amplify.Auth.confirmSignIn(new Password) and catch error NotAuthorizedException.
  4. So, after Amplify.Auth.signOut() not global, call Amplify.Auth.signIn(ID, temporary password) again.
  5. catch InvalidStateException. This is the same until you taskkill the app.

Code Snippet

// Put your code below this line.

Log output


~call SignOut(local)
2022-11-21 15:40:12.582 Amplify.Auth.signOut     D  Signed out with Local
~call SignIn()
2022-11-21 15:40:12.582 Amplify.Auth.signIn-st   D  userId=XXXXX@XXXXXXXX/userPassword=XXXXXXXXXX
2022-11-21 15:40:12.583 Amplify.co...thConfig()  D  Auth just became signed out.
2022-11-21 15:40:15.630 Amplify.Auth.signIn      D  isSignedIn=Sign in not complete
2022-11-21 15:40:15.630 Amplify.Auth.signIn      D  nextStep.signInStep=CONFIRM_SIGN_IN_WITH_NEW_PASSWORD

~wait 5min, and call ComfirmSignIn() 
2022-11-21 15:45:31.121 Amplify.Au...firmSignIn  D  Sign in failed AmplifyException+NotAuthorizedException/ NotAuthorizedException(message=Invalid session for the user, session is expired.)

~call SignOut(local)
2022-11-21 15:45:57.486 Amplify.Auth.signOut     D  Signed out with Local
~call SignIn() again
2022-11-21 15:45:57.486 Amplify.Auth.signIn-st   D  userId=XXXXX@XXXXXXXX/userPassword=XXXXXXXXXX
2022-11-21 15:45:57.509 Amplify.Auth.signIn      D  Sign in failed AmplifyException InvalidStateException{message=Auth state is an invalid state, cannot process the request., cause=null, recoverySuggestion=Operation performed is not a valid operation for the current auth state.}



amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@tylerjroach tylerjroach added bug Something isn't working auth Related to the Auth category/plugins labels Nov 21, 2022
@gpanshu
Copy link
Contributor

gpanshu commented Nov 21, 2022

Hi @sayamimi thank you so much for opening this issue. We are looking into this and will get back to you once we have an answer.

@gpanshu
Copy link
Contributor

gpanshu commented Dec 27, 2022

I apologize for not being able to reply sooner. This has been fixed and merged in and will be available to you with the next update of Amplify in the upcoming weeks. I will reply here once the update is out to close out the ticket so you do not have to monitor it.

@gpanshu
Copy link
Contributor

gpanshu commented Dec 29, 2022

This has now been released. Please update to the latest version 2.1.0 and this has been resolved.

@gpanshu gpanshu closed this as completed Dec 29, 2022
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Related to the Auth category/plugins bug Something isn't working
Projects
None yet
3 participants