2

TemporaryPassword 上的 Amazon Cognito adminCreateUser 文档指出:

该参数不是必需的。如果您未指定值,Amazon Cognito 会为您生成一个值。

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

这是我在节点 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"
    }
}

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

4

2 回答 2

1

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

临时密码通过电子邮件发送给用户,他需要在第一次登录时重新设置。

于 2017-03-31T18:46:34.767 回答
0

答案是用户电子邮件需要经过验证才能收到。因此,您需要修改电子邮件上的用户属性以进行验证。请参阅:https ://stackoverflow.com/a/43033722/491553

于 2017-08-08T17:33:09.720 回答