简体   繁体   中英

Android AWS Amplify.Auth.signUp() / AWSMobileClient.getInstance().signUp() have same errorCodes for error cases

How to distinguish error cases for signUp process?

Only one case (password's length is less then 6) is different to others (both for Amplify and AWSMobileClient solutions):

  • user password less then 6 symbols:

{ InvalidParameterException @11448} "com.amazonaws.services.cognitoidentityprovider.model.InvalidParameterException: 1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6 (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException ; Request ID: 1f65fd14-0d11-483a-9fc2-1dfc9854127e)"

  • user password satisfy above demand, but does't not contain uppercase characters:

{ InvalidPasswordException @11481} "com.amazonaws.services.cognitoidentityprovider.model.InvalidPasswordException: Password did not conform with policy: Password must have uppercase characters (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: InvalidPasswordException ; Request ID: 2d046ca6-d462-4165-bf27-5575ce806b22)"

  • user password satisfy above two demands, but does't not contain numeric characters:

{ InvalidPasswordException @11525} "com.amazonaws.services.cognitoidentityprovider.model.InvalidPasswordException: Password did not conform with policy: Password must have numeric characters (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: InvalidPasswordException ; Request ID: b657ff9e-520a-429a-982f-29c1695ca1bd)"

the same errorCode for case when password doesn't contain special symbols like.@#$% etc.

But for Amplify.Auth.confirmSignUp() / AWSMobileClient.getInstance().confirmSignUp() I have different errorCodes:

val errorMessage = when (exAws.errorCode) {
    "AliasExistsException" -> 
        mess = 'An account with the email already exists.'

    "CodeMismatchException" ->
        mess = 'Invalid verification code provided, please try again.'

    .  .  .  .  .   
}

Yes, currently Amplify Auth and AWSMobileClient use errorCode of exactly the same name but different types. For Amplify Auth, the error type is Amplify.AuthException . Could you please specify your question with more details?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM