Monday, June 3, 2024
82
rated 0 times [  87] [ 5]  / answers: 1 / hits: 67980  / 8 Years ago, wed, june 29, 2016, 12:00:00

So in my app I obviously want to provide the means for users to reset their passwords. The issue I'm having though is that the new documentation for User Pools is pretty ambiguous on this topic. Here is what they tell you to do for a Forgot Password flow, and the link you may find it at:



cognitoUser.forgotPassword({
onSuccess: function (result) {
console.log('call result: ' + result);
},
onFailure: function(err) {
alert(err);
},
inputVerificationCode() {
var verificationCode = prompt('Please input verification code ' ,'');
var newPassword = prompt('Enter new password ' ,'');
cognitoUser.confirmPassword(verificationCode, newPassword, this);
}
});


http://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-javascript-examples.html



However when I drop this code into my project where a cognitoUser is defined and signed in, nothing seems to happen. I understand I need to somehow integrate this code with sending a verification code to the user, and asking them for a new password, but can't find anything on how to do this. Thoughts?



Thanks


More From » amazon-web-services

 Answers
11

Resetting the password with forgot password flow has two steps:




  1. Start the process by requesting for a verification code from the service. A code will be delivered to the user's phone/email.

  2. Set the new password using the delivered verification code.



Use these two functions to perform the above steps and reset the password:




  1. cognitoUser.forgotPassword(): This will start the forgot password process flow. The service generates a verification code and sends it to the user. The data, returned through callback.inputVerificationCode(data), indicates where the verification code was sent.


  2. cognitoUser.confirmPassword(): Use the delivered verification code with this function to set a new password.



[#61573] Tuesday, June 28, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bethv

Total Points: 215
Total Questions: 101
Total Answers: 89

Location: Angola
Member since Wed, Jun 2, 2021
3 Years ago
;