简体   繁体   中英

What is proper username in Cognito User Pool?

I need to check that a proper username is entered in the custom signin form on my web site to pass it to Auth.signUp method of aws-amplify.

Things like minimum/maximum number of characters and allowed characters.

Documentation at this link does not help, please point me to a correct page, thank you!

See AWS SDK for validation rules.

The username for the user. Must be unique within the user pool. Must be a UTF-8 string between 1 and 128 characters . After the user is created, the username can't be changed.

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cognito-identity-provider/interfaces/admincreateusercommandinput.html

Not perhaps a perfect description but has at least the minimum and maximum character count.

Edit: Cognito API reference reveals that regex pattern for username validation is: [\p{L}\p{M}\p{S}\p{N}\p{P}]+

https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html

BTW, username cannot be changed after creation so perhaps you want to use preferred_username attribute to store the username which a user submits in sign in form (and make back-end to generate a value for username automatically (uuid for example)).

The document behind the link states:

Activate the preferred_username attribute so that your user can change the user name that they use to sign in while their username attribute value doesn't change.

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