furaiev / amazon-cognito-identity-dart-2

Unofficial Amazon Cognito Identity Provider Dart SDK, to easily add user sign-up and sign-in to your mobile and web apps with AWS.
MIT License
187 stars 114 forks source link

Correct exception is not thrown from SignIn #30

Closed droidkfx closed 4 years ago

droidkfx commented 4 years ago

The following snippet from the package README does not work as expected

CognitoUserSession session;
try {
  session = await cognitoUser.authenticateUser(authDetails);
...
} on CognitoUserConfirmationNecessaryException catch (e) {
  // handle User Confirmation Necessary
} on CognitoClientException catch (e) {
  // handle Wrong Username and Password and Cognito Client
}
...

When using this code CognitoUserConfirmationNecessaryException is not thrown. Rather:

CognitoClientException{statusCode: 400, code: UserNotConfirmedException, name: UserNotConfirmedException, message: User is not confirmed.}

Expected Behavior: Correct exception should be thrown so the client can handle the challenge appropriately.