Cognito - Can't change user status from FORCE_CHANGE_PASSWORD
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.
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.
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
Well, I have this all working now. Future people running into this problem should check my answer in the Stack Overflow link above.
👍 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.