【问题标题】:Post Confirmation ConfirmForgotPassword lambda execution returns InvalidLambdaResponseException - Unrecognizable lambda output确认后 ConfirmForgotPassword lambda 执行返回 InvalidLambdaResponseException - 无法识别的 lambda 输出
【发布时间】:2022-01-15 13:50:54
【问题描述】:

我花了很多时间来解决这个问题,所有相关的 SO 答案似乎都已过时或无关紧要。

状态:

  • Amplify.js "^4.3.10" 和代码

         Auth.forgotPasswordSubmit(email, confirmationCode, password)
         .then(_ => this.notification.success("Confirmation OK"))
         .catch(err => console.log(err));
    
  • Node.js 14 上的 Lambda

  • Cognito 触发“发布确认”

Lambda 函数代码:

'use strict';

exports.handler = async (event, context, callback) => {
    if (event.triggerSource === "PostConfirmation_ConfirmForgotPassword") {
      const postConfirmEmail = () => `<html><body>HERE IS MY TEMPLATE</body></html>`;
    
      event.response = {
          emailSubject: "Reset Password Notification",
          emailMessage: postConfirmEmail()
      };
      
      callback(null, event);
    } 
};

结果,我得到了 InvalidLambdaResponseException:无法识别的 lambda 输出(错误 400)

问题是密码确实按预期更新,但未发送电子邮件确认并且错误仍然存​​在。

提示:用户已确认。也尝试使用“context.done(null, event);” /“返回事件;”但是响应总是出现同样的错误。

【问题讨论】:

    标签: authentication aws-lambda amazon-cognito amplify


    【解决方案1】:

    您不应该在回调中使用异步处理程序。要么是一个,要么是另一个。

    直接返回 event 而不调用回调或者不要让你的函数异步。

    此外,Cognito 不会发送确认电子邮件,您必须自己实现此功能。

    【讨论】:

      猜你喜欢
      • 2017-07-31
      • 2019-03-15
      • 2020-11-06
      • 2022-06-22
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 2013-02-11
      • 2018-04-08
      相关资源
      最近更新 更多