Bug
Lib throws
Username cannot be empty
Accept signUp action without errors.
I've set up my cognito so that it doesn't use username, only email and password.
So why your lib throws Username cannot be empty
? This is definitely wrong behaviour!
If I call .signUp
this way (params as strings, no username
), all works as expected, no errors thrown:
Auth.signUp(email, password)
.then( data => {
// All is OK, we here
} )
.catch( err => {
} );
If I call this way (params as an object), your SDK throws. Why? It is not consistent. I need to call this way because I have attributes
to pass to Cognito.
See your docs https://aws.github.io/aws-amplify/media/authentication_guide#working-with-user-attributes, I need to use object params, but it doesn't work when object!
Auth.signUp( {email, password, attributes: {
foo: 'bar'
}})
.then( data => {
} )
.catch( err => {
// `Username cannot be empty` // Why?
} );
I had a very similar issue too, when you go into AWS cognito make sure that the signup type is set to email not username or email aliases configurations. I would recommend walking through in the UI the creation of the user pool in the aws mobilehub to see what you can do.
@dallinwright
It is already set. That's why I don't understand their error
Ah I see a potential error. Even though it is set to email, you have to pass the email as the username like my function below. I would agree that it doesn't make much sense but you have to do it similar to this way.
Auth.signUp({
username: this.signupForm.get('email').value.toLowerCase( ),
password: this.signupForm.get('password').value,
attributes: {
email: this.signupForm.get('email').value.toLowerCase( ),
given_name: this.signupForm.get('given_name').value,
family_name: this.signupForm.get('family_name').value
},
validationData: []
}).then(() => {
this.router.navigate(['unverified']);
}).catch(err => {
this.errorMessage = err;
});
Feel free to reopen it if you are still facing this issue.
I have the same issue using the react aws-amplify
lib.
Here is the documentation about this topic:
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases-settings-option-2
Most helpful comment
Ah I see a potential error. Even though it is set to email, you have to pass the email as the username like my function below. I would agree that it doesn't make much sense but you have to do it similar to this way.