Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将用户电话号码属性更新为AWS cognito,并使用node.js通过sms mfa验证电话号码_Node.js_Amazon Cognito_Multi Factor Authentication_Totp - Fatal编程技术网

将用户电话号码属性更新为AWS cognito,并使用node.js通过sms mfa验证电话号码

将用户电话号码属性更新为AWS cognito,并使用node.js通过sms mfa验证电话号码,node.js,amazon-cognito,multi-factor-authentication,totp,Node.js,Amazon Cognito,Multi Factor Authentication,Totp,有人能帮我满足以上要求吗 我们必须更新AWS cognito中的phone_number属性,并发送SMS MFA以确认手机号码。我们还必须验证发送给用户的代码。如果在设置中启用了电话验证,Cognito会自动执行此操作。只需运行UpdateUserAttributes函数并设置一个新的电话号码 当然可以。您需要使用AWS SDK const AWS = require('aws-sdk'); const config = require('./config'); function upda

有人能帮我满足以上要求吗


我们必须更新AWS cognito中的phone_number属性,并发送SMS MFA以确认手机号码。我们还必须验证发送给用户的代码。

如果在设置中启用了电话验证,Cognito会自动执行此操作。只需运行UpdateUserAttributes函数并设置一个新的电话号码


当然可以。您需要使用AWS SDK

const AWS = require('aws-sdk');
const config = require('./config'); 

function updateAttribute(params) {
    AWS.config.update({
        'region' : config.AWSConfig.region,
        'accessKeyId': config.AWSConfig.accessKeyId,
        'secretAccessKey': config.AWSConfig.secretAccessKey
    });
    let cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider();

    let parameters = { UserPoolId : config.userPoolDetails.userPoolId,
    Username : params.userName,
    UserAttributes : [
        {
            'Name': params.nameOfAttribute ,
            'Value': params.newValueOfAttribute
        },
    ]}
    
    cognitoIdentityServiceProvider.adminUpdateUserAttributes(parameters,function (err, result) {
        if(err)
        console.log(err);
        else
        console.log("Attribute updated successfully");
    })
}

let params = {
    userName : 'username',
    nameOfAttribute : 'name',
    newValueOfAttribute : 'Sachin'
}

updateAttribute(params);

您甚至可以像这样添加新属性

您可以在此处阅读更多内容: