aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.68k stars 880 forks source link

AWSMobileClient confirmSignIn success callback not called and IOS app crashing #3480

Closed TijiJoy closed 3 years ago

TijiJoy commented 3 years ago

Create 2 new user from backend/cognito with password change required 1-Login with first user 2-Force change password with new user 3-Fill OTP and confirm login 4-Logout with user 5-Login with second user 6-Force change password with new password Crash happens And it is happening with two different applications with iOS only and for Android both applications working with same steps

error is as follows: NSInternalInconsistencyException Cannot set the result on a completed task

App is crashing when we call this method AWSMobileClient.default().confirmSignIn(challengeResponse: password)

func setNewPassword(_ password: String) {

AWSMobileClient.default().confirmSignIn(challengeResponse: password) { (signInResult, error) in

        if let signInResult = signInResult {

            switch(signInResult.signInState) {
            case .signedIn:

                 DispatchQueue.main.async {

                                       UserDefaults.standard.set(true, forKey: "isLoggedin")
                                       self.dismiss(animated: true, completion: nil)
                                        self.changeRoot()
                                                        }
            case .smsMFA:

                DispatchQueue.main.async(execute: {

                 let storyboard = UIStoryboard(name: "Main", bundle: nil)
                 let vc = storyboard.instantiateViewController(withIdentifier: "MFAViewController")as!MFAViewController       
                             vc.modalPresentationStyle = .fullScreen
                              self.present(vc, animated: true, completion: nil)
                 })

            default:
                print("Other signIn state: \(signInResult.signInState.rawValue)")
            }
        } else if let customError = error as? AWSMobileClientError {

                  print(customError)

                          DispatchQueue.main.async {

                                            print(customError)

                        }
                    }
    }

}

palpatim commented 3 years ago

@TijiJoy Can you confirm the version of the SDK you're running, and the version of iOS you're seeing this crash on?

palpatim commented 3 years ago

This seems like a fairly unusual use case. Is this still affecting your app? If so, please let us know the version of the SDK you're running, and the version of iOS you're seeing this crash on. If not, we're not inclined to spend too much time trying to dig into this.

TijiJoy commented 3 years ago

Hi, Check the screenshot below for the details of SDK and this issue is observed in almost all iPhones.

With Regards, Tiji Joy

On Sat, Apr 10, 2021 at 12:05 AM Tim Schmelter @.***> wrote:

This seems like a fairly unusual use case. Is this still affecting your app? If so, please let us know the version of the SDK you're running, and the version of iOS you're seeing this crash on. If not, we're not inclined to spend too much time trying to dig into this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/aws-sdk-ios/issues/3480#issuecomment-816880283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSJGPYFXMZQIKYQOY7X5GTTH5CG3ANCNFSM4ZW6364Q .

-- With Regards Tiji Joy M

TijiJoy commented 3 years ago

From ios version 13.6 only we have recognised this issue.But not sure if it was present in before versions also.Because we have tested this scenario first in ios 13.6 version

On Mon, Apr 12, 2021 at 10:59 AM Acoustic Malayali @.***> wrote:

Hi, Check the screenshot below for the details of SDK and this issue is observed in almost all iPhones.

With Regards, Tiji Joy

On Sat, Apr 10, 2021 at 12:05 AM Tim Schmelter @.***> wrote:

This seems like a fairly unusual use case. Is this still affecting your app? If so, please let us know the version of the SDK you're running, and the version of iOS you're seeing this crash on. If not, we're not inclined to spend too much time trying to dig into this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/aws-sdk-ios/issues/3480#issuecomment-816880283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSJGPYFXMZQIKYQOY7X5GTTH5CG3ANCNFSM4ZW6364Q .

-- With Regards Tiji Joy M

-- With Regards Tiji Joy M

palpatim commented 3 years ago

OK, thanks for confirming. Can you provide the SDK version you're using?

TijiJoy commented 3 years ago

ios sdk version is 19.1

On Wed, Apr 14, 2021 at 10:11 PM Tim Schmelter @.***> wrote:

OK, thanks for confirming. Can you provide the SDK version you're using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/aws-sdk-ios/issues/3480#issuecomment-819660150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSJGP3LNOZ4RFRXO4IWAKDTIXAR7ANCNFSM4ZW6364Q .

-- With Regards Tiji Joy M

royjit commented 3 years ago

@palpatim meant the AWS iOS SDK version that you using in your app. The latest AWS iOS SDK version is 2.23.3 - https://github.com/aws-amplify/aws-sdk-ios/releases/tag/2.23.3. Please check whether you can reproduce the issue in the latest AWS iOS SDK.

TijiJoy commented 3 years ago

Hi,

I updated aws SDK to the latest version and still getting the same crash.

On Fri, Apr 16, 2021, 10:38 PM Jithin Roy @.***> wrote:

@palpatim https://github.com/palpatim meant the AWS iOS SDK version that you using in your app. The latest AWS iOS SDK version is 2.23.3 - https://github.com/aws-amplify/aws-sdk-ios/releases/tag/2.23.3. Please check whether you can reproduce the issue in the latest AWS iOS SDK.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/aws-sdk-ios/issues/3480#issuecomment-821316185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSJGP5UKCXNE4RXRIWK3FLTJBVJNANCNFSM4ZW6364Q .

royjit commented 3 years ago

I have tried following your step and was not able to reproduce the crash. These are the steps I followed:

  1. Created two user in AWS console - "testuser1" and "testuser2". The two user are in state FORCE_CHANGE_PASSWORD
  2. Created a sample app and called AWSMobileClient.signIn with "testuser1" and then AWSMobileClient.confirmSignIn with new password. The user was signed in successfully
  3. Then I signedout the user
  4. Now I signed in the user "testuser2" by calling AWSMobileClient.signIn and then AWSMobileClient.confirmSignIn . The user signed in successfully.

Could you please provide the stack trace of the crash to help us debug further.

TijiJoy commented 3 years ago

Hi ,

Did you close the application from background before doing second user login?.In this case app will work.

But if you just login as user1 signout and move to login screen and login with second user then app will crash when you call confirm signin.

On Sat, May 29, 2021, 5:17 AM Jithin Roy @.***> wrote:

I have tried following your step and was not able to reproduce the crash. These are the steps I followed:

  1. Created two user in AWS console - "testuser1" and "testuser2". The two user are in state FORCE_CHANGE_PASSWORD
  2. Created a sample app and called AWSMobileClient.signIn with "testuser1" and then AWSMobileClient.confirmSignIn with new password. The user was signed in successfully
  3. Then I signedout the user
  4. Now I signed in the user "testuser2" by calling AWSMobileClient.signIn and then AWSMobileClient.confirmSignIn . The user signed in successfully.

Could you please provide the stack trace of the crash to help us debug further.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws-amplify/aws-sdk-ios/issues/3480#issuecomment-850726880, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSJGP4OJ4S4H5AFWYMQJ73TQATQFANCNFSM4ZW6364Q .

royjit commented 3 years ago

I did not close the app before second user login. Please provide us with the crash stack trace to debug further.

TijiJoy commented 3 years ago
Screenshot 2021-06-01 at 9 42 44 PM

Hi,

The error is still reproducible at our end.It actually happens with third user. 1)User 'A' already logged in with his credentials 2) User 'A ' logout from application 3)Use new user Testuser1 credentials and confirm signin ->login successfully ->logout 4)Use new user Testuser2 credentials and confirnSignin -> app crashes.

Screenshot 2021-06-01 at 9 42 44 PM
royjit commented 3 years ago

I have again tested the same flow with multiple users, please find the screen recording of the same.

https://user-images.githubusercontent.com/51138777/124517998-41964000-dd9a-11eb-9b81-6c8ae2838a4b.mov

Please note that confirmSignIn should not be called if the signIn api return SignInState. signedIn.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open for 14 days with no activity. Please, provide an update or it will be automatically closed in 7 days.

diegocstn commented 3 years ago

Closing due to inactivity but feel free to re-open if you need more help.