It seems obvious that Cognito is attempting to validate the username passed and finding that it is not a valid email address, despite me supplying a valid email. Cognito is unlikely to be buggy, so I dug into the sample code supplied by AWS. In the js/cognito-auth.js file I found that where the username parameter is being passed to Cognito it is wrapped in a toUsername() function:
userPool.signUp(toUsername(email), password, [attributeEmail], null,
The function replaces the @ in the email with -at-:
function toUsername(email) {
return email.replace('@', '-at-');
}
I took the quick way out and updated the toUsername() function:
function toUsername(email) {
return email;
}
After pushing the change to CodeCommit and waiting for Amplify to deploy it, my registration and Sign in works. The sample code I changed was straight from AWS, so I'm not sure how this crept in, could be:
- I made a mistake with the user pool setup, though I was pretty careful and it's all the defaults
- Something has changed with the default setup of a User Pool
- Cognito has added validation forcing the user name to be a email.
Anyway, I'm posting this to assist if others experience it.