如何使用 AWS Amplify 在注册页面中添加自定义字段

问题描述 投票:0回答:2

我使用 AWS Amplify 开发了一个简单的应用程序,并使用 amplify add auth 添加了基本身份验证。我选择了“电子邮件或电话号码”选项,它起作用了。现在我想添加更多字段,例如

1- first name
2- city
3- country
4- last name

知道我需要在哪里实施这个吗?我可以使用 Amplify ADMIN UI 执行此操作吗?谢谢:)

amazon-web-services aws-amplify serverless aws-amplify-cli
2个回答
0
投票

对于自定义属性

  1. 从 AWS 控制台,转到用户池并选择

    Sign-up Experience
    选项卡。您可以运行
    amplify console auth
    ,然后选择
    User Pool
    为您打开控制台。

  2. 向下滚动到自定义属性,然后添加自定义字段,我添加了

    icecream

    注意:自定义属性创建后无法重命名或删除。 Amazon Cognito 在自定义属性名称前面添加“custom:”。

  3. 然后编辑您的

    amplify-authenticator

    指令,如下所示:

我将其拼凑在一起的文档:

https://ui.docs.amplify.aws/components/authenticator?platform=angular#force-new-password-fields
重要提示:文本字段中的 name

 属性的格式为 
custom:YOUR_CUSTOM_FIELD

<!-- angular version here --> <amplify-authenticator> <ng-template amplifySlot="sign-up-form-fields"> <amplify-sign-up-form-fields></amplify-sign-up-form-fields> <amplify-text-field label="Icecream" autocomplete="false" placeholder="Your Icecream" name="custom:icecream" type="text"> </amplify-text-field> </ng-template> </amplify-authenticator>
用于添加额外的标准属性

    奔跑
  1. amplify update auth
    
    
  2. 选择
  3. Walkthrough all the auth configurations
    
    
  4. 当提示
  5. 指定读取属性指定写入属性时,选择您想要在应用程序中启用的属性。 https://docs.amplify.aws/guides/authentication/managing-user-attributes/q/platform/js/#configuring-standard-attributes
  6. 然后将它们添加到您的注册表单指令中:
<amplify-authenticator [signUpAttributes]="['address','preferred_username']"></amplify-authenticator>
    

0
投票
现在,这些类型的选项(“custom:xxx”)已被弃用。

他们发布了又一个选项来添加自定义属性。

有关这些属性的更多信息可以在此处找到

如果您想添加自定义属性, CognitoUserAttributeKey.custom(_key):

,

    _key 表示自定义属性常量字符串。
  1. attribute_value 表示属性的值
示例: CognitoUserAttributeKey.custom("村庄"): "Nachipatty",

© www.soinside.com 2019 - 2024. All rights reserved.