我正在尝试使用AWS Cognito SDK设置Cognito用户,但在向用户添加自定义属性时遇到问题。我确保变量名称完全匹配,并且应用程序允许对所有属性进行读/写。 我的代码如下所示:
var attributeList = [];
var dataName = {
Name: 'name',
Value: name
};
var dataPhoneNumber = {
Name: 'phone_number',
Value: phone
};
var dataIsDriver = {
Name: 'custom:is_driver',
Value: 0
};
var attributeName = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataName);
var attributePhoneNumber = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataPhoneNumber);
var attributeIsDriver = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute(dataIsDriver);
attributeList.push(attributeName);
attributeList.push(attributePhoneNumber);
attributeList.push(attributeIsDriver);
var username = generateUUID();
localStorage.setItem("username", username);
var userPool = getUserPool();
userPool.signUp(username, password, attributeList, null, function (err, result) {
if (err) {
alert(err);
return;
}
}
使用此代码,正确设置了name和phone_number属性,但没有“is_driver”。我尝试使用adminGetUser获取用户属性的全部,但is_driver仍然没有出现。任何指导将不胜感激!