AnomalyInnovations / aws-api-gateway-cli-test

A simple CLI to test API Gateway endpoints with IAM authorization
MIT License
120 stars 29 forks source link

cognitoUser.authenticateUser needs a newPasswordRequired callback #3

Closed forrest-akin closed 6 years ago

forrest-akin commented 6 years ago

If the cognito user being authenticated is signing in for the first time, they might need to set a new password as well as any other required attributes. I don't think there's a way of pausing execution to accept more args with yargs (maybe with Vorpal), but here's the function signature for newPasswordRequired to be added to the callback object in cognitoUser.authenticateUser(authenticationDetails, callbacks)


newPasswordRequired: function (userAttributes, requiredAttributes) {
  // User was signed up by an admin and must provide new
  // password and required attributes, if any, to complete
  // authentication.

  // userAttributes: object, which is the user's current profile. It will list all attributes that are associated with the user.
  // Required attributes according to schema, which don’t have any values yet, will have blank values.
  // requiredAttributes: list of attributes that must be set by the user along with new password to complete the sign-in.

  // Get these details and call
  // newPassword: password that user has given
  // attributesData: object with key as attribute name and value that the user has given.
  cognitoUser.completeNewPasswordChallenge({NEW_PASSWORD}, {REQUIRED_ATTRIBUTES}, this)
}
jayair commented 6 years ago

@forrest-akin I was wondering if this is worth handling. I think we should throw the appropriate error for sure. But I'm not sure if we want to help people set a new password through this tool.

forrest-akin commented 6 years ago

Agreed. For people following the guide step-by-step, it isn't required. I needed it because I was using bits and pieces of the guide to fill in the gaps for what I'm working on. A helpful error message should suffice!

jayair commented 6 years ago

Makes sense. Just updated it.

forrest-akin commented 6 years ago

Looks good, thanks!