3

I use amazon-cognito-identity-js for cognito pool data.

Please look at my forgetPassword.js code:

const response = await AwsForgetPassword(this.state.email)
      .then(response => {
        console.log(response);
      })
      .catch(error => {
        console.log(error);
      });

and below my AwsForgetPassword.js code:

const AmazonCognitoIdentity = require("amazon-cognito-identity-js");

global.navigator = () => null;
export const AwsForgetPassword = email => {
  const poolData = {
    UserPoolId: "XX_XXXX-XXX", // Your user pool id here
    ClientId: "xxxxxxxxxxxxx" // Your client id here
  };
  const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
  var userData = {
    Username: email,
    Pool: userPool
  };
  //console.log(userData);
  var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
  return new Promise((resolve, reject) => {
    cognitoUser.forgotPassword({
      onSuccess: function(data) {
        // successfully initiated reset password request
        // console.log(data);

        return resolve(data);
      },
      onFailure: function(err) {
        // console.log(err);
        return reject(err);
        //]  alert(err.message || JSON.stringify(err));
      }

    });
  });
};

I haven't got any response in forgetPassword.js and I get a verification code in the mail for valid email. Something missing please let me know I have to spend lot's time in it.

Subhash Patel
  • 674
  • 7
  • 16

2 Answers2

4

Check the aws server-side settings related to cache.

It may be possible that you are getting the cached response from the server or network.

Vandit Mehta
  • 2,572
  • 26
  • 41
1

Your onSuccess callback in cognitoUser.forgotPassword function contains data as an argument but you are returning resolve(result)!

It should return resolve(data)

abdoo_salem
  • 312
  • 3
  • 9