When creating a new cognito user, I would like to confirm their account through the Pre Sign-up lambda. It looks as follows:
exports.handler = (event, context, callback) => {
// Confirm the user
event.response.autoConfirmUser = true;
// Set the email as verified if it is in the request
if (event.request.userAttributes.hasOwnProperty("email")) {
event.response.autoVerifyEmail = true;
}
// Set the phone number as verified if it is in the request
if (event.request.userAttributes.hasOwnProperty("phone_number")) {
event.response.autoVerifyPhone = true;
}
console.info("EVENT\n" + JSON.stringify(event, null, 2))
console.info("CONTEXT\n" + JSON.stringify(context, null, 2))
// Return to Amazon Cognito
callback(null, event);
};
I cloudWatch logs I get
"response": {
"autoConfirmUser": true,
"autoVerifyEmail": true,
"autoVerifyPhone": true
}
but in cognito user is not verified phone_number_verified=false, email_verified=false and user status is FORCE_CHANGE_PASSWORD instead of CONFIRMED