AdminCreateUserRequest creates a Cognito user. After the creation is complete, the user status in the Cognito console is "Forced to change password". Is there any way to avoid forced password change during creation?
AdminCreateUserRequest userRequest = AdminCreateUserRequest.builder()
.userPoolId(userPoolId)
.username(name)
.temporaryPassword(password)
.userAttributes(userAttrs)
.messageAction("SUPPRESS")
.build();
In the code, determine whether the status is FORCE_CHANGE_PASSWORD. If so, use AdminSetUserPasswordRequest to change the password (the original password). The main code is .password(newPassword) and .permanent(true). But I don't think this is a direct solution to the problem.
AdminSetUserPasswordRequest setUserPasswordRequest = AdminSetUserPasswordRequest.builder()
.userPoolId(userPoolId)
.username(username)
.password(newPassword)
.permanent(true)
.build();
I checked the official documentation and code, and it seems that I do need to set the password again.