如何在 completeNewPassword 上设置自定义属性?
How can I set a custom attribute on completeNewPassword?
我有以下代码
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 中,角色属性未显示为必需属性。我该如何设置?
好的,我之前的回答不正确,所以为了后代我删除了它。
显然我们必须先设置自定义属性的读写权限,然后才能使用 Amplify 进行设置。
酷 - 我们在哪里有这个设置? NOT 在 Cognito 控制台的“属性”选项卡中。它隐藏在 APP CLIENTS 选项卡中,一直位于底部的一个名为 Set attribute read and write permissions
的切换按钮下。选中您的自定义属性的复选框即可。
糟糕的用户体验,但至少我现在有了答案。
来源:https://forums.aws.amazon.com/message.jspa?messageID=882666
我有以下代码
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 中,角色属性未显示为必需属性。我该如何设置?
好的,我之前的回答不正确,所以为了后代我删除了它。
显然我们必须先设置自定义属性的读写权限,然后才能使用 Amplify 进行设置。
酷 - 我们在哪里有这个设置? NOT 在 Cognito 控制台的“属性”选项卡中。它隐藏在 APP CLIENTS 选项卡中,一直位于底部的一个名为 Set attribute read and write permissions
的切换按钮下。选中您的自定义属性的复选框即可。
糟糕的用户体验,但至少我现在有了答案。
来源:https://forums.aws.amazon.com/message.jspa?messageID=882666