aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Cognito - Can't change user status from FORCE_CHANGE_PASSWORD

Open rsshilli opened this issue 9 years ago • 4 comments

Hello,

I'm essentially re-opening #2264. I'm creating a user for a test case by calling adminCreateUser. Here's the response I get back after creating the user:

{
    "User": {
            "Username": "qdbvision-test__mailinator.com",
            "Attributes": [
                    {
                            "Name": "custom:title",
                            "Value": "Made up title"
                    },
                    {
                            "Name": "sub",
                            "Value": "cb4d077f-c425-4225-abba-df13286c7a14"
                    },
                    {
                            "Name": "name",
                            "Value": "Ryan Rocket"
                    },
                    {
                            "Name": "phone_number",
                            "Value": "+15124262345"
                    },
                    {
                            "Name": "given_name",
                            "Value": "Ryan"
                    },
                    {
                            "Name": "family_name",
                            "Value": "Rocket"
                    },
                    {
                            "Name": "email",
                            "Value": "[email protected]"
                    },
                    {
                            "Name": "custom:company",
                            "Value": "Rockets R US"
                    }
            ],
            "UserCreateDate": "2017-02-17T20:57:36.813Z",
            "UserLastModifiedDate": "2017-02-17T20:57:36.813Z",
            "Enabled": true,
            "UserStatus": "FORCE_CHANGE_PASSWORD"
    }
}

Note the UserStatus is FORCE_CHANGE_PASSWORD. I can login to the AWS console and see that the user was created and has that status there too.

Now when I try to login, through the browser using the cognitoUser.authenticateUser() command (as in this example), I would expect to have my newPasswordRequired method be called, but it isn't. The response I see in Chrome's devtools coming back from Cognito is:

{"__type":"UserNotFoundException","message":"User does not exist."}

Similarly, I've tried to call cognitoIdentityServiceProvider.adminInitiateAuth() from the back end too (vaguely following this). When I do that, I get:

{ [UserNotFoundException: User does not exist.]
  message: 'User does not exist.',
  code: 'UserNotFoundException',
  time: Fri Feb 17 2017 14:57:38 GMT-0600 (Central Standard Time),
  requestId: 'b647102f-f553-11e6-a8d6-d13dae9a6114',
  statusCode: 400,
  retryable: false,

How does a person go about setting the new user's password?

And FWIW, as long as the user exists in the AWS console, I wouldn't expect to get a UserNotFoundException.

rsshilli avatar Feb 17 '17 21:02 rsshilli

Unfortunately, I am not too knowledgeable about the specifics of how you would do this through Cognito's API (the AWS CLI is pretty much a 1:1 mapping to the API). I would recommend asking this question on Stack Overflow, the AWS Developer Forums, or AWS Support as outlined in our README.

kyleknap avatar Feb 22 '17 23:02 kyleknap

Well, that's disappointing. It's already a long standing question on Stack Overflow:

http://stackoverflow.com/questions/40287012/how-to-change-user-status-force-change-password

rsshilli avatar Feb 25 '17 16:02 rsshilli

Well, I have this all working now. Future people running into this problem should check my answer in the Stack Overflow link above.

rsshilli avatar Jul 28 '17 22:07 rsshilli

👍 This is a much needed feature. Especially when thinking about test users in CI etc.

Related the android client crashes when a user in this state signs in [https://github.com/aws/aws-sdk-android/issues/374]

These two combined has me looking for workable alternatives.

ollyjshaw avatar Mar 20 '18 13:03 ollyjshaw