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

'User Confirmation Necessary' Exception - But User is confirmed #103

Closed mdridley closed 3 years ago

mdridley commented 3 years ago

I saw the other thread, but tried re-sending confirmation code and I get: 'User is already confirmed.'

I was able to authenticate with the user using AWS Amplify as well. Any ideas on what I am missing.

My Login:

final cognitoUser = new CognitoUser(username, userPool);
      final authDetails = new AuthenticationDetails(
      username: username,
      password: password,
    );
    CognitoUserSession session;
    try {
      session = await cognitoUser.authenticateUser(authDetails);
    } on CognitoClientException catch (e) {
      print(e);
    } on CognitoUserConfirmationNecessaryException catch (e) {
      await cognitoUser.resendConfirmationCode();
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text(
              'User account is not confirmed. Confirmation code has been resent'),
          backgroundColor: COLOR_ERROR,
        ),
      );
    } catch (e) {
      print(e);
    }