angular - 如何在 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 设置它。
酷 - 我们在哪里有这个设置?不在Cognito 控制台的“属性”选项卡中。它一直隐藏在APP CLIENTS选项卡底部的一个名为Set attribute read and write permissions
. 选中您的自定义属性的复选框,您就拥有了。
糟糕的用户体验,但至少我现在有了答案。
来源:https ://forums.aws.amazon.com/message.jspa?messageID=882666
推荐阅读
- python - Jupyter notebook tensorflow pandas 绘图错误
- r - 您可以将小标题的名称存储到列表中以供以后访问吗?
- flutter - Flutter 中的视频播放器错误 com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException
- mysql - 带计数器的 MySQL
- flutter - 在 Flutter 中创建信息弹出窗口
- c# - MYSQL 创建表未创建所有字段
- python - 当我添加一些代码时,其余部分停止工作
- kotlin - 我需要制作没有大边框的 kotlin jar 应用程序
- visual-studio-2019 - Blazor Web Assembly App .Net Core Hosted:发布运行时错误
- c# - 文本框不返回 Visual C# 中的当前值