-
Notifications
You must be signed in to change notification settings - Fork 93
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
Allow NEW_PASSWORD_REQUIRED challenge completion. #22
base: master
Are you sure you want to change the base?
Conversation
Cognito allows users to be created via an admin user. The new user gets a temporary password and is expected to change that password via a challenge response. This allows that flow by making use of some existing code. Signed-off-by: Nick Campbell <[email protected]>
As I looked through more of the code, it seemed like there may be other places that could use the common function than just the two for which I impl it. I can go through and make the others use that if you'd like before landing this pr. Let me know. |
Bump. |
Thanks for the PR @ncb000gt. I'll try to find some time this week to look into this. Been super busy on my end here -- sorry for the late responses. |
No worries. I know how it feels running a few open source projects myself. ;D Thanks! FWIW- This code is running in my Flutter app. |
Cognito allows users to be created via an admin user. The new user gets a temporary password and is expected to change that password via a challenge response. This allows that flow by making use of some existing code. Signed-off-by: Nick Campbell <[email protected]> jonsaw#22
@@ -657,6 +657,18 @@ class CognitoUser { | |||
return data; | |||
} | |||
|
|||
Future<void> completeNewPasswordChallenge(String newPassword) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we don't want to pass back some status of whether the new password challenge was successful or failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any issue passing back the response personally. However, I understood this lib to use exceptions for flow control. So my thoughts were that if there was a problem that the client would except and that you'd have to appropriately deal with that.
Still, I don't have any reservations about responding with a good or bad signal to the caller. @jonsaw what are your thoughts on this?
@ncb000gt Any chance you can provide a sample example of how to use this? I'm having some trouble where when I call completeNewPasswordChallenge, it's being invoked with a null cognito user and null session. My current flow is:
|
@aneeshjoshi I'm using this library in Flutter so YMMV. I'm using this inside my mobile app. I attempt to
Then I render the "new password" form. I've held onto the
At this point I just require that the user login again. I do think your point above is relevant, re: if the user doesn't enter the right password conforming to whatever specifications you've laid out...but again, I'd expect that an exception would be thrown. I should probably verify that part somewhere. ;D Does that help? |
That does help. I'm new to flutter and this lib, so I need to figure out
how to maintain access to the cognito user. I had trouble where each
rebuild of the widget was resetting my user service and underlying objects.
Not sure what the idiomatic dart/flutter way to deal with this is. For now
I'm trying to keep a user service as a static instance on MyApp level
widget.
…On Thu, Nov 15, 2018 at 5:36 PM Nick Campbell ***@***.***> wrote:
@aneeshjoshi <https://github.com/aneeshjoshi> I'm using this library in
Flutter so YMMV.
I'm using this inside my mobile app. I attempt to login. If that fails,
an exception is thrown and I catch that with:
} on CognitoUserNewPasswordRequiredException catch (e) {
message = 'It looks like this is your first time logging in. You need to specify a new password.';
...
Then I render the "new password" form. I've held onto the CognitoUser()
object I used to attempt the login in the first place and call:
myCognitoUser.completeNewPasswordChallenge("MY new PASSWORD!");
At this point I just require that the user login again.
I do think your point above is relevant, re: if the user doesn't enter the
right password conforming to whatever specifications you've laid out...but
again, I'd expect that an exception would be thrown. I should probably
verify that part somewhere. ;D
Does that help?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADEfayRg9u4rQiCPrAcpTg-a7yXULi4zks5uvexsgaJpZM4WqJYw>
.
|
@aneeshjoshi Yea. I'm not entirely sure of the idiomatic dart/flutter approach, but the way I handled it was put a "service" layer that is a singleton inside the app. That maintains the CognitoUser state across the application. Then I have "listeners" that are notified of changes to auth state which will then return the user to the login screen. I settled on this approach, but I believe you could end up doing something similar or better using the BLoC approach in flutter. I just never got a chance to do that. Once the app is built and functional I'm expecting to rework a lot of parts of it. :) |
Cognito allows users to be created via an admin user. The new user gets a temporary password and is expected to change that password via a challenge response. This allows that flow by making use of some existing code. Signed-off-by: Nick Campbell <[email protected]> jonsaw#22
logins like Google or Facebook.
…s/amazon-cognito-identity-dart into new_password_required_challenge
Cognito allows users to be created via an admin user. The new user gets a temporary password and is expected to change that password via a challenge response. This allows that flow by making use of some existing code. Signed-off-by: Nick Campbell <[email protected]> jonsaw#22
This PR is no longer "clean" since I inadvertently pushed changes up to my branch that @BerndWessels made to one of his PRs...I can recreate the original pr if you really want. |
@jonsaw ping. |
Hello there, Changes look safe. Can we merge this to master? |
@jonsaw any chance of this being merged into master? |
Hi all here, |
I know a bunch of people have commented here. I've just implemented and tested Hope that helps anyone here who is still struggling with this and thanks to @jonsaw for all the initial work on this project. It was really helpful. Thanks to @furaiev for picking it up for the next phase. |
Cognito allows users to be created via an admin user. The new user gets
a temporary password and is expected to change that password via a
challenge response. This allows that flow by making use of some existing
code.
Signed-off-by: Nick Campbell [email protected]