简体   繁体   English

Cognito 用户池中的正确用户名是什么?

[英]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.我需要检查是否在我的 web 站点的自定义登录表单中输入了正确的用户名,以将其传递给 aws-amplify 的 Auth.signUp 方法。

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.有关验证规则,请参阅 AWS SDK。

The username for the user.用户的用户名。 Must be unique within the user pool.在用户池中必须是唯一的。 Must be a UTF-8 string between 1 and 128 characters .必须是 1 到 128 个字符之间的 UTF-8 字符串 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 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}]+编辑:Cognito API 参考显示用户名验证的正则表达式模式是: [\p{L}\p{M}\p{S}\p{N}\p{P}]+

https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html 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)).顺便说一句,用户名在创建后无法更改,因此您可能想使用 preferred_username 属性来存储用户在登录表单中提交的用户名(并让后端自动为用户名生成一个值(例如 uuid))。

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.激活 preferred_username 属性,以便您的用户可以更改他们用于登录的用户名,而他们的用户名属性值不变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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