amazon-cognito-identity-dart icon indicating copy to clipboard operation
amazon-cognito-identity-dart copied to clipboard

CognitoUser.authenticateUser keeps throwing an exception.

Open ncb000gt opened this issue 7 years ago • 7 comments

Thanks for putting this out there. I ran into an issue trying to authenticate using the library so I broke the code out into an example application and was able to isolate the issue to lib/cognito_user.dart:144.

Receiver: Instance of 'Future'
Tried calling: []("UserConfirmationNecessary") - #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
#1      CognitoUser._authenticateUserInternal (package:amazon_cognito_identity_dart/src/cognito_user.dart:144:20)
<asynchronous suspension>
#2      CognitoUser._authenticateUserDefaultAuth (package:amazon_cognito_identity_dart/src/cognito_user.dart:627:12)
<asynchronous suspension>
#3      CognitoUser.authenticateUser (package:amazon_cognito_identity_dart/src/cognito_user.dart:436:20)
<asynchronous suspension>
#4      AuthService.login (file:///Users/ncampbell/Code/flutter_cognito_auth_test/lib/auth.dart:122:34)
<asynchronous suspension>
#5      _AuthGatewayState.submit (file:///Users/ncampbell/Code/flutter_cognito_auth_test/lib/main.dart:68:23)
<asynchronous suspension>
#6      _AuthGatewayState.build.<anonymous closure>.<anonymous closure> (file:///Users/<…>

I noticed the issue in 0.0.17 and pulled master to double check. The issue exists there as well.

I have a fix in a branch I'm working on and will push a PR up for it once I'm comfortable that all the issues are resolved.

ncb000gt avatar Jun 26 '18 01:06 ncb000gt

Even with the fix in GH-17 I am still running into an issue:

flutter: errrr: CognitoUserException: User Confirmation Necessary - #0      CognitoUser._authenticateUserInternal (package:amazon_cognito_identity_dart/src/cognito_user.dart:146:7)
<asynchronous suspension>
#1      CognitoUser._authenticateUserDefaultAuth (package:amazon_cognito_identity_dart/src/cognito_user.dart:628:12)
<asynchronous suspension>
#2      CognitoUser.authenticateUser (package:amazon_cognito_identity_dart/src/cognito_user.dart:437:20)
<asynchronous suspension>
#3      AuthService.login (file:///Users/ncampbell/Code/flutter_cognito_auth_test/lib/auth.dart:122:34)
<asynchronous suspension>
#4      _AuthGatewayState.submit (file:///Users/ncampbell/Code/flutter_cognito_auth_test/lib/main.dart:68:23)
<asynchronous suspension>
#5      _AuthGatewayState.build.<anonymous closure>.<anonymous closure> (file:///Users/ncampbell/Code/flutter_cognito_auth_test/lib/main.dart:148:13)
#6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:494:14)
#7      _InkResponseSta<…>

It seems as though it isn't confirming the device, but I'm not really sure why that's not working. Any ideas?

ncb000gt avatar Jun 26 '18 01:06 ncb000gt

I added && !_signInUserSession.isValid() to line cognito_user.dart:145 which seems to be the right approach. But, I didn't want to push that up as I've only spent a small amount of time with the code.

I can add that to the PR if you agree.

ncb000gt avatar Jun 26 '18 14:06 ncb000gt

Thanks for the find + feedback. Will look into it!

jonsaw avatar Jun 27 '18 12:06 jonsaw

@jonsaw any thoughts regarding the && !_signInUserSession.isValid() bit?

ncb000gt avatar Aug 24 '18 02:08 ncb000gt

Sorry for the late reply. Is your setup close to the one found on Serverless Stack?

jonsaw avatar Nov 10 '18 08:11 jonsaw

@jonsaw yea. it's very similar except that i'm not using a custom domain for the the app auth because i'm handling it internally through two means, a flutter mobile app (using this lib) and through the web using amplify.

I haven't spent much more time digging into this either on my end. I suppose I should put it on my roadmap. ;D If I find anything else about this I'll post here.

ncb000gt avatar Nov 10 '18 15:11 ncb000gt

I have the same problem. I also added && !_signInUserSession.isValid() to line cognito_user.dart:145 to temporary resolve this problem.

MashaFomina avatar Feb 18 '19 14:02 MashaFomina