0

我正在尝试自动确认使用signUpCognito API 创建的用户。它运行良好,它在我的池中创建了一个 CONFIRMED 用户。但它抛出了这个错误:

Unrecognizable lambda output

我还在 PostConfirmation Cognito 触发器中收到了正确的事件格式:

{
  version: '1',
  region: 'blabla',
  userPoolId: 'blabla',
  userName: 'blabla',
  callerContext: {
    awsSdkVersion: 'blabla',
    clientId: 'blabla'
  },
  triggerSource: 'PostConfirmation_ConfirmSignUp',
  request: {
    userAttributes: {
      sub: 'blabla',
      'cognito:email_alias': 'blabla',
      email_verified: 'true',
      'cognito:user_status': 'CONFIRMED',
      name: 'blabla',
      'custom:is_created_from_ccw': '1',
      'custom:permanent_password': 'blabla',
      email: 'blabla'
    }
  },
  response: {}
}

CreateUser功能:

class CognitoClient {
    static async signUpUser({ name, email }) {
        const psw = passwordGenerator(15);
        
        return cognito
            .signUp({
                ClientId: process.env.COGNITO_CLIENT_ID,
                Password: psw,
                Username: email,
                UserAttributes: [
                    {
                        Name: 'name',
                        Value: name,
                    },
                    {
                        Name: 'email',
                        Value: email,
                    },
                    {
                        Name: 'custom:is_created_from_ccw',
                        Value: '1',
                    },
                    {
                        Name: 'custom:permanent_password',
                        Value: psw,
                    },
                ],
            })
            .promise();
    }
}

Pre-signup拉姆达:

exports.handler = (event, context, callback) => {
    // custom logic here for other cases...

    // Confirm the user
    event.response.autoConfirmUser = true;
    event.response.autoVerifyEmail = true;

    // Return to Amazon Cognito
    callback(null, event);
}

奇怪的是,当尝试设置时event.response.autoVerifyEmail = falseevent.response.autoConfirmUser = false它不会抛出任何错误......

有人可以告诉我我做错了什么吗?谢谢你!!

4

0 回答 0