node.js - AWS Cognito Trigger Post Authenticated - Lambda Nodejs 8.10 - 返回自定义响应错误 TypeError:无法设置属性
问题描述
我正在尝试构建一个与 AWS Cognito 集成的 Web 应用程序。
当我使用 Node.js 8.10 创建一个 lambda 函数来返回特定的响应对象时,我收到一个错误:
exports.handler = (event, context, callback) => {
event["response"] = {
"test": "testing"
}
event.done(null, event);
};
代码很简单:
WebApp 登录 -> Cognito 用户池 -> 身份验证后触发器 -> Lambda 函数。
我需要的是,当 Cognito Post Authentication Trigger 调用 lambda 函数并返回带有对象的响应时,该响应会返回给 WebApp。
我的登录提交处理程序类似于:
handleLoginSubmit = async event => {
event.preventDefault();
this.props.isLoading(true);
if(this.validateForm()) {
this.props.isLoading(false);
return;
}
try {
await Auth.signIn(this.state.email, this.state.password);
Auth.currentAuthenticatedUser()
.then(user => {
console.log("cognito return", user);
this.props.userHasAuthenticated(true);
})
.catch(err => console.log("error: ",err));
} catch (e) {
console.log('error currentAuthenticatedUser: ', e);
this.props.isLoading(false);
}
}
登录工作,好的。
但我永远无法检索我试图通过的 response.test。
如何检索从 lambda 发送到 Cognito 的 Post Authentication 触发器的响应?
解决方案
推荐阅读
- c# - Blazor 服务器身份验证
- jestjs - 如何测试“获取”包括跨源请求的凭据
- python - 我正在 pygame 上制作游戏,但是当我进入“WIN.blit”时,它给了我一个错误
- r - 多个 netcdf 文件函数定义特定的 lat lon
- mod-rewrite - 如何创建 RewriteRule 以同时使用主域和子域?
- c++ - 这个命令行是什么意思
- makefile - makefile 中的百分比运算符不适用于子文件夹
- r - 根据日期(以及更多)拆分、过滤和选择数据
- javascript - Javascript - 数组
- java - 如果spring数据JPA不存在,如何处理并发创建