Guest User

Untitled

a guest
Jun 8th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. function ChangePassword(username, password, newpassword) {
  2. var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({
  3. Username: username,
  4. Password: password,
  5. });
  6.  
  7. var userData = {
  8. Username: username,
  9. Pool: userPool
  10. };
  11. var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
  12.  
  13. cognitoUser.authenticateUser(authenticationDetails, {
  14. onSuccess: function (result) {
  15. cognitoUser.changePassword(password, newpassword, (err, result) => {
  16. if (err) {
  17. console.log(err);
  18. } else {
  19. console.log("Successfully changed password of the user.");
  20. console.log(result);
  21. }
  22. });
  23. },
  24. onFailure: function (err) {
  25. console.log(err);
  26. },
  27. });
  28. }
Add Comment
Please, Sign In to add comment