【问题标题】:Can AWS Cognito adminCreateUser send a temporary password?AWS Cognito adminCreateUser 可以发送临时密码吗?
【发布时间】:2017-08-09 01:33:09
【问题描述】:

TemporaryPassword 上的 Amazon Cognito adminCreateUser documentation 状态:

此参数不是必需的。如果您不指定值,亚马逊 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"
    }
}

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

【问题讨论】:

    标签: node.js amazon-cognito aws-cognito


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2019-01-18
        • 1970-01-01
        • 2017-03-21
        • 1970-01-01
        • 2011-12-12
        • 2017-07-03
        • 2021-08-28
        • 1970-01-01
        • 2022-08-13
        相关资源
        最近更新 更多