【问题标题】:How can I set a custom attribute on completeNewPassword?如何在 completeNewPassword 上设置自定义属性?
【发布时间】:2021-07-30 15:11:33
【问题描述】:

我有以下代码

Auth.completeNewPassword(
        user,
        this.profileForm.get('newPassword')?.value,
        {
          "phone_number": String(this.profileForm.get('phone')?.value),
          "given_name": this.profileForm.get('fName')?.value,
          "family_name": this.profileForm.get('lName')?.value,
          "locale": this.profileForm.get('language')?.value,
          "custom:role": "user" // Error when this line is added
        }
      )
      .then(data => console.log("Changed Password! -->", data))
      .catch(err => console.log("Password change failed: ", err));

它在custom:role 行失败,我收到以下错误:

`Input attributes include non-writable attributes for the client XXXX`

此外,在 Cognito 中,角色属性不会显示为必需属性。我该如何设置?

【问题讨论】:

    标签: angular aws-amplify


    【解决方案1】:

    好的,我之前的答案不正确,所以我将其删除以供后人使用。

    显然我们必须先设置自定义属性的读写权限,然后才能使用 Amplify 设置它。

    酷 - 我们在哪里有这个设置? NOT 在 Cognito 控制台的“属性”选项卡中。它一直隐藏在 APP CLIENTS 选项卡底部的一个名为 Set attribute read and write permissions 的切换按钮下。选中您的自定义属性的复选框,您就拥有了。

    糟糕的用户体验,但至少我现在有了答案。

    来源:https://forums.aws.amazon.com/message.jspa?messageID=882666

    【讨论】:

      猜你喜欢
      • 2021-07-21
      • 1970-01-01
      • 2018-04-11
      • 1970-01-01
      • 2011-11-23
      • 2017-03-06
      • 2017-06-12
      • 2012-12-17
      • 1970-01-01
      相关资源
      最近更新 更多