Authentication using AWS Cognito

Viewed 80

I have a scenario where user enters only email address. An auto generated password should be sent to the given user's email id which is to be auto verified. What i have tried is something called a lambda function on pre-signUp which auto verifies the email address but the issue that occurs is when i try to have a custom email lambda it is not being called/working.But when i disable the pre-signUp lambda the custom email works. Please help me with this issue.

code for preSignup:

exports.handler = (event, context, callback) => {
    // Set the user pool autoConfirmUser flag after validating the email domain
    event.response.autoConfirmUser = true;
     event.response.autoVerifyEmail = true;

    // Split the email address so we can compare domains
    var address = event.request.userAttributes.email.split("@")
    
    // This example uses a custom attribute "custom:domain"
    if (event.request.userAttributes.hasOwnProperty("custom:domain")) {
        if ( event.request.userAttributes['custom:domain'] === address[1]) {
            event.response.autoConfirmUser = true;
        }
    }
    

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