Amazon web services 如何在Cognito';s注册过程

Amazon web services 如何在Cognito';s注册过程,amazon-web-services,amazon-cognito,Amazon Web Services,Amazon Cognito,我在重新发送确认码时遇到问题,因为某些原因,确认码没有发送给用户。这就是我所拥有的: 首先,我有一个注册步骤: const cognito = new AWS.CognitoIdentityServiceProvider({region}); const params = { ClientId, Username, Password, }; const result = await cognito.signUp(params).promise(); 此步骤(如果成功)应

我在重新发送确认码时遇到问题,因为某些原因,确认码没有发送给用户。这就是我所拥有的:

首先,我有一个注册步骤:

const cognito = new AWS.CognitoIdentityServiceProvider({region});
const params = {
    ClientId,
    Username,
    Password,
};
const result = await cognito.signUp(params).promise();
此步骤(如果成功)应向用户的电子邮件地址(这也是他们的用户名)发送一封带有确认码的电子邮件。现在让我们假设由于某种原因电子邮件没有发送(原因本身并不重要)。我想为用户提供一个机会,要求发送新的电子邮件。到目前为止,我一直在为此目的进行以下测试:

首先,我测试了
resendConfirmationCode
方法:

const cognito = new AWS.CognitoIdentityServiceProvider({region});
const params = {
    ClientId,
    Username,
};
const result = await cognito.resendConfirmationCode(params).promise();
执行此代码将抛出以下错误消息:

UnhandledPromiseRejectionWarning: NotAuthorizedException: Cannot resend codes. Auto verification not turned on.
然后,我测试了这种方法(因为中给出了答案):

这一次,我得到了这个错误:

UnhandledPromiseRejectionWarning: UnsupportedUserStateException: Resend not possible. ********-****-****-****-********** status is not FORCE_CHANGE_PASSWORD
缩回部分是用户的子部件


那么,有人知道我如何为尚未确认的用户重新发送确认码吗?

对于可能面临此问题的任何其他人,这是因为用户池的设置一开始就不发送验证码。以下是如何启用在用户池上发送验证代码:

  • 转到Coginto和用户池
  • 转到“MFA和验证”页面
  • 在“要验证哪些属性?”部分中,选择其中一项(对我来说是“电子邮件”)
  • 但对我来说,实际的问题是,这个选项最初是在早些时候正确设置的。但当我执行此命令时,它被重置为“无验证”:

    aws cognito-idp update-user-pool \
        --region us-east-1 \
        --user-pool-id us-east-1_********* \
        --lambda-config CustomMessage=arn:aws:lambda:us-east-1:************:function:composeEmail
    
    该命令应该引入lambda函数来编写验证代码的电子邮件。但出于某种原因,它也会重置其他设置,我不知道为什么

    在任何情况下,一旦设置正确,我的第一个解决方案将起作用:

    const cognito = new AWS.CognitoIdentityServiceProvider({region});
    const params = {
        ClientId,
        Username,
    };
    const result = await cognito.resendConfirmationCode(params).promise();
    

    与AWS支持人员聊天后,您可以指定如下验证属性:

    aws cognito-idp update-user-pool \ --region us-east-1 \ --user-pool-id us-east-1_********* \ --lambda-config CustomMessage=arn:aws:lambda:us-east-1:************:function:composeEmail --auto-verified-attributes email aws cognito idp更新用户池\ --美国东部1区\ --用户池id us-east-1*******\ --lambda config CustomMessage=arn:aws:lambda:us-east-1:*************:函数:composeEmail --自动验证属性电子邮件 aws cognito-idp update-user-pool \ --region us-east-1 \ --user-pool-id us-east-1_********* \ --lambda-config CustomMessage=arn:aws:lambda:us-east-1:************:function:composeEmail --auto-verified-attributes email