gpt4 book ai didi

javascript - AWS Cognito - SerializationException(在不期望的位置找到结构或 map 的开始)

转载 作者:太空狗 更新时间:2023-10-29 18:02:40 31 4
gpt4 key购买 nike

我在 Cognito 用户池中创建了一个用户,如图所示,使用创建用户选项,并希望该用户在首次登录时设置新密码。为此,我使用下面给定的方法,如 AWS 文档中给出的 Create User from AWS

cognitouser.completeNewPasswordChallenge()

下面是我的代码

//Start: setNewPasswordForAdmin
setNewPasswordForAdmin(username: string, password: string) {

//Start: Creating new user with username and pool data
const adminUserdata = {
Username: username,
Pool: userpoolAdmin
}
const adminuser = new CognitoUser(adminUserdata);
//End: Creating new user with username and pool data


//create attributelist array which will contain all the attributes requried for signing in
//these attributes are those attributes, which are selected while creating user pool on aws
const attributeList : CognitoUserAttribute[] = [];

//form a json object containing Name and Value of attribute used
const usernameattribute = {
Name:'username',
Value: username
}

//Push list of attributes in the attributeList array
attributeList.push(new CognitoUserAttribute(usernameattribute));
console.log(attributeList);
const that = this;

adminuser.completeNewPasswordChallenge(password, attributeList ,{
onFailure(err){

console.log(err);
},
onSuccess(result){
console.log(":::::::: Password change successfull ");

that.router.navigate(['']);
}
});
}
//End: setNewPasswordForAdmin

执行此操作后,我收到一条错误消息,

{code: "SerializationException", name: "SerializationException", message: "Start of structure or map found where not expected."}

这些是我在用户池中选择的属性

List Of Attributes and permissions in user pool

请帮我解决这个问题。

最佳答案

在我的例子中,它最终被发送到我的 resetPassword 助手的格式错误的数据。该函数正在寻找三个参数(用户名代码密码):

export default function (username, code, password) {

}

……我将它们作为对象发送:

yield call(authResetPassword, {
code: DOMPurify.sanitize(verificationCode),
username: DOMPurify.sanitize(email),
password: DOMPurify.sanitize(newPassword),
})

我刚刚更新了助手,一切就绪!

export default function ({ username, code, password }) {

}

只需将您的数据记录到 setNewPasswordForAdmin 函数中,我敢打赌您会发现那里有问题。

关于javascript - AWS Cognito - SerializationException(在不期望的位置找到结构或 map 的开始),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49934800/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com