title: How to resend confirmation code in Cognito's sign-up process
body: <p>I'm having issues with resending the confirmation code for cases where for some reason the confirmation code was not delivered to the users. This is what I have:</p>
  
  <p>First, I have a sign-up step:</p>
  
  <pre><code>const cognito = new AWS.CognitoIdentityServiceProvider({region});
  const params = {
      ClientId,
      Username,
      Password,
  };
  const result = await cognito.signUp(params).promise();
  </code></pre>
  
  <p>This step (in case of success) should send an email to the user's email address (which is also their username) with their confirmation code. Now let's assume for some reason that email is not sent (the reason itself is not important). I would like to provide a chance to the user to ask for a new email to be sent. These are what I've been testing for this purpose so far:</p>
  
  <p>First, I've tested the <code>resendConfirmationCode</code> method:</p>
  
  <pre><code>const cognito = new AWS.CognitoIdentityServiceProvider({region});
  const params = {
      ClientId,
      Username,
  };
  const result = await cognito.resendConfirmationCode(params).promise();
  </code></pre>
  
  <p>Executing this code throws this error message:</p>
  
  <pre><code>UnhandledPromiseRejectionWarning: NotAuthorizedException: Cannot resend codes. Auto verification not turned on.
  </code></pre>
  
  <p>Then, I tested this approach (because of the answer given in <a href="https://stackoverflow.com/questions/53194794/cant-resend-verification-code-through-aws-cognito-api">this post</a>):</p>
  
  <pre><code>const cognito = new AWS.CognitoIdentityServiceProvider({region});
  const params = {
    UserPoolId,
    Username,
    DesiredDeliveryMediums: ["EMAIL"],
    ForceAliasCreation: false,
    MessageAction: "RESEND",
  }
  const result = await cognito.adminCreateUser(params).promise();
  </code></pre>
  
  <p>This time, I'm getting this error:</p>
  
  <pre><code>UnhandledPromiseRejectionWarning: UnsupportedUserStateException: Resend not possible. ********-****-****-****-********** status is not FORCE_CHANGE_PASSWORD
  </code></pre>
  
  <p>The retracted part is the user's sub.</p>
  
  <p>So, does anyone know how I can resend the confirmation code for a user that is not confirmed yet?</p>