2
votes

AWS Cognito is sending 6 digits verification code for mobile/email verification.

Is there any way to customize the size of the verification code?
Ex: changing it to 4 digits

I went through the AWS documentation but couldn't find any solution.

Thanks in Advance

1

1 Answers

2
votes

No, you cannot change the internal logic of cognito.

However, you can create your own logic to verify users. You can create a pre signup lambda to send random 4 digit code to email of the newly created user (you can store the temporary code in custom user attribute which is hidden from user or in dynamodb table with userid for comparison later). Then create another lambda which has AdminUpdateUserAttributes privileges in the role. This lambda will get triggered by apigateway which will take the 4 digit code as input. Then compare this code to the one you stored earlier. If it matches, make the AdminUpdateUserAttributes call and mark the user verified.