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

标签 node.js amazon-cognito

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/

相关文章:

node.js - 我们是否应该始终避免 NodeJS 中的普通 for 循环以提高并发性?

node.js - 使用 knexjs 创建角色

amazon-web-services - 自定义 UI 的 Cognito 授权代码授予流程

amazon-web-services - API 网关授权方接受 ID_token 但不接受 Access_Token

ios - 如何在 iOS 上获取 Cognito 用户池 "sub"属性

ios - Cognito/IAM 策略和 S3 获取对象

javascript - 如何在js中实现去抖动

jquery - 使用 socket.io 提供静态文件的问题

javascript - Mocha/Should.js 使用异步函数

amazon-web-services - 如何为不同的用户启用预签名的 S3 URL?