amazon-web-services - AWS 无法识别的 Lambda 输出 Cognito 错误

标签 amazon-web-services triggers amazon-cognito

我最近开始使用 AWS。我已经使用 cognito 用户池集成了 AWS Amplify 进行用户管理(登录和注册),它非常完美(只要有新用户注册,用户池就会更新)。现在我添加了一个 Cognito Post 确认触发器以将注册的电子邮件保存到数据库中,这是我的触发器代码 mysql = require('mysql');

var config = require('./config.json');

var pool = mysql.createPool({

host : config.dbhost,

user : config.dbuser,

password : config.dbpassword,

database : config.dbname

});

exports.handler = (event, context, callback) => {

let inserts = [event.request.userAttributes.email];

context.callbackWaitsForEmptyEventLoop = false; //prevents duplicate entry

pool.getConnection(function(error, connection) {

connection.query({

sql: 'INSERT INTO users (Email) VALUES (?);',

timeout: 40000, // 40s

values: inserts

}, function (error, results, fields) {

// And done with the connection.

connection.release();

// Handle error after the release.

if (error) callback(error);

else callback(null, results);

});

});

};

每当用户注册并确认他的电子邮件时,这个触发器就会调用并向我抛出这个错误 “无法识别的 Lambda 输出 Cognito”。尽管它在后台抛出了这个错误,但我的数据库正在插入新注册的电子邮件,但由于这个原因,我无法重定向我的页面。任何帮助将不胜感激。谢谢

亚拉文

最佳答案

简答:callback(null, results); 替换为 callback(null, event);

原因:您必须返回结果,Cognito 将使用它继续身份验证工作流程。在本例中,这是 event 对象。

关于amazon-web-services - AWS 无法识别的 Lambda 输出 Cognito 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59650985/

相关文章:

ubuntu - ec2 实例的公共(public) ip 重定向到私有(private) ip

mysql - 无法触发运行

java.lang.IllegalArgumentException : Failed to read S3TransferUtility please check your setup or awsconfiguration. json 文件

amazon-web-services - 更改 cognito 用户池用户状态

amazon-web-services - 不存在的导出/输出阻止堆栈更新/删除

amazon-web-services - 将本地Kibana连接到远程AWS Elasticsearch端点吗?

amazon-web-services - 带有 AWS S3 文件的 Icecast 服务器

amazon-web-services - 如何在 AWS Batch 上使用 docker compose?

oracle - 语句触发器 PL/SQL

MYSQL - 用于将 VARCHAR 中的时间转换为 INTEGER 中的秒的触发器正在插入多行,而它应该只插入