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

Do you think it would be worth it to add a change password screen? #16

Open
quantuminformation opened this issue Nov 11, 2017 · 1 comment

Comments

@quantuminformation
Copy link

Similar to red-gold/react-social-network#36

@jayair
Copy link
Member

jayair commented Nov 11, 2017

@quantuminformation I think we can make it an extra chapter possibly. It's not hard to do but it does complicate the app a bit more by having to create an extra screen.

But in case other folks find this thread here are some ideas on how to implement it.

  • Get the current Cognito user object by calling getCurrentCognitoUser from src/libs/awsLib.js

  • Ensure that user is authenticated by calling getUserToken again from src/libs/awsLib.js

  • Finally, use the Cognito JS SDK changePassword to change the user's password to the new one they set.

      cognitoUser.changePassword('oldPassword', 'newPassword', function(err, result) {
          if (err) {
              alert(err);
              return;
          }
          console.log('call result: ' + result);
      });

These are the steps to change their password using the Cognito JS SDK but you still need to create a form in React to ask your user to type in their old password and the new password.

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

No branches or pull requests

2 participants