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

CognitoUser.authenticateUser keeps throwing an exception. #16

Open
ncb000gt opened this issue Jun 26, 2018 · 7 comments · May be fixed by #46
Open

CognitoUser.authenticateUser keeps throwing an exception. #16

ncb000gt opened this issue Jun 26, 2018 · 7 comments · May be fixed by #46

Comments

@ncb000gt
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@jonsaw
Copy link
Owner

jonsaw commented Jun 27, 2018

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

jonsaw added a commit that referenced this issue Jul 2, 2018
GH-16 await on confirm device before keying into object.
@ncb000gt
Copy link
Contributor Author

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

@jonsaw
Copy link
Owner

jonsaw commented Nov 10, 2018

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

@ncb000gt
Copy link
Contributor Author

@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.

@MashaFomina
Copy link

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

@kanhaic kanhaic linked a pull request May 18, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants