gpt4 book ai didi

node.js - AWS Cognito adminCreateUser 可以发送临时密码吗?

转载 作者:太空宇宙 更新时间:2023-11-04 00:24:58 29 4
gpt4 key购买 nike

Amazon Cognito adminCreateUser documentation临时密码状态:

This parameter is not required. If you do not specify a value, Amazon Cognito generates one for you.

用户如何获得它?起初我以为它会通过电子邮件发送给用户,但情况似乎并非如此。然后我想也许它会在响应中返回。不。

这是我在 Node JS Lambda 函数中调用的代码:

adminCreateUser(
{
"UserPoolId": "us-east-1_XXXXXXXX",
"Username": "roger__mailinator.com",
"DesiredDeliveryMediums": [
"EMAIL"
],
"ForceAliasCreation": false,
"MessageAction": "SUPPRESS",
"UserAttributes": [
{
"Name": "given_name",
"Value": "Rodger"
},
{
"Name": "family_name",
"Value": "Ribbit"
},
{
"Name": "name",
"Value": "Rodger Ribbit"
},
{
"Name": "email",
"Value": "roger@mailinator.com"
},
{
"Name": "custom:title",
"Value": "Animation Designer"
},
{
"Name": "custom:company",
"Value": "76"
}
]
}, function(error, data) {
if (error) {
console.log("Error adding user to cognito: " + error, error.stack);
//...
} else {
console.log("Received back from cognito: " + JSON.stringify(data));
//...
}
});

这是我得到的回复:

Received back from cognito:
{
"User": {
"Username": "roger__mailinator.com",
"Attributes": [
{
"Name": "custom:title",
"Value": "Animation Designer"
},
{
"Name": "sub",
"Value": "1cd612a0-0da0-4e7b-84c7-30570fab80a9"
},
{
"Name": "name",
"Value": "Rodger Ribbit"
},
{
"Name": "given_name",
"Value": "Rodger"
},
{
"Name": "family_name",
"Value": "Ribbit"
},
{
"Name": "email",
"Value": "roger@mailinator.com"
},
{
"Name": "custom:company",
"Value": "76"
}
],
"UserCreateDate": "2017-03-30T18:31:34.283Z",
"UserLastModifiedDate": "2017-03-30T18:31:34.283Z",
"Enabled": true,
"UserStatus": "FORCE_CHANGE_PASSWORD"
}
}

密码去哪里了?我们应该猜到吗? :-)

最佳答案

我认为这是因为您正在传递“MessageAction”:“SUPPRESS”。这将抑制电子邮件的发送。

临时密码通过电子邮件发送给用户,用户首次登录时需要重置。

关于node.js - AWS Cognito adminCreateUser 可以发送临时密码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43126153/

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