How to change User Status FORCE_CHANGE_PASSWORD?

前端 未结 12 1924
我在风中等你
我在风中等你 2020-12-07 08:15

Using AWS Cognito, I want to create dummy users for testing purposes.

I then use the AWS Console to create such user, but the user has its status s

12条回答
  •  攒了一身酷
    2020-12-07 08:24

    You can change that user status FORCE_CHANGE_PASSWORD by calling respondToAuthChallenge() on the user like this:

    var params = {
      ChallengeName: 'NEW_PASSWORD_REQUIRED', 
      ClientId: 'your_own3j6...0obh',
      ChallengeResponses: {
        USERNAME: 'user3',
        NEW_PASSWORD: 'changed12345'
      },
      Session: 'xxxxxxxxxxZDMcRu-5u...sCvrmZb6tHY'
    };
    
    cognitoidentityserviceprovider.respondToAuthChallenge(params, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });
    

    After this, you'll see in the console that user3 status is CONFIRMED.

提交回复
热议问题