-
-
Save itsrajverma/29e349c11f044ac0f9c2aeedabdc61a6 to your computer and use it in GitHub Desktop.
Change-Password-Cognito
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ChangePassword(username, password, newpassword) { | |
| var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({ | |
| Username: username, | |
| Password: password, | |
| }); | |
| var userData = { | |
| Username: username, | |
| Pool: userPool | |
| }; | |
| var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); | |
| cognitoUser.authenticateUser(authenticationDetails, { | |
| onSuccess: function (result) { | |
| cognitoUser.changePassword(password, newpassword, (err, result) => { | |
| if (err) { | |
| console.log(err); | |
| } else { | |
| console.log("Successfully changed password of the user."); | |
| console.log(result); | |
| } | |
| }); | |
| }, | |
| onFailure: function (err) { | |
| console.log(err); | |
| }, | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment