The description of a Cognito User Pools Pre Sign-up Lambda Trigger is:
This trigger is invoked when a user submits their information to sign up, allowing you to perform custom validation to accept or deny the sign up request.
I want to deny a sign-up request based on a certain condition in my Lambda. The trigger parameters (reproduced from the docs below) seem to only support auto-verification and auto-confirmation:
{
"request": {
"userAttributes": {
"string": "string",
....
},
"validationData": {
"string": "string",
"string": "string",
....
}
},
"response": {
"autoConfirmUser": "boolean",
"autoVerifyPhone": "boolean",
"autoVerifyEmail": "boolean"
}
}
How can I accept or deny a sign-up request based on the outcome of the Pre Sign-up Lambda Trigger?
With a user pool, your app users can sign in through the user pool or federate through a third-party identity provider (IdP). Identity pools are for authorization (access control). You can use identity pools to create unique identities for users and give them access to other AWS services.
Go to AWS Cognito service and click “Manage Identity Pools”. 2. Enter “Identity pool name”, expand the “Authentication providers” section and select “Cognito” tab. This is where the Cognito authentication provider will be registered with the Identity pool.
Amazon Cognito is designed for developers who want to add user management and sync functionality to their mobile and web apps. Developers can use Cognito Identity to add sign-up and sign-in to their apps and to enable their users to securely access their app's resources.
You can deny signup by throwing an exception, as shown here.
The exception message will be passed back to Cognito, and on to the client, in the form of a validation error with the message PreSignUp failed with error {exceptionMessage}.
.
You can return a empty dict from the lambda to deny sign up request. Similarly you return the event value itself to accept the sign up request.
def lambda_handler(event, context):
if denySignUp:
return {}
else:
return event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With