I've successfully created a lambda function using Go for the pre sign-up trigger of AWS Cognito. My problem is that I'm not being able to deny/reject the user if a custom field is not valid (based on custom logic).
I'm returning an error as described in AWS Cognito trigger's guide:
return event, fmt.Errorf("Invalid value for field 'custom:myField'")
also I've tried this options:
-
returning an empty event (nil is not allowed for the event):
var emptyEvent events.CognitoEventUserPoolsPreSignup return emptyEvent, fmt.Errorf("Invalid value for field 'custom:myField'")
-
changing ValidationData in the original event:
event.Request.ValidationData = map[string]string{"custom:myField": "Invalid value for field 'custom:myField."} return event, fmt.Errorf("Invalid value for field 'custom:myField'")
-
changing UserAttributes in the original event
event.Request.UserAttributes["email"] = "" return event, fmt.Errorf("Invalid value for field 'custom:myField'")
All those methods are failing, the user is always created in the User Pool.
What should be the correct way to reject the sign-up request using GoLang lambda function?