-
Notifications
You must be signed in to change notification settings - Fork 451
Python pres signup cognito trigger #633
Comments
You can try debugging from the lambda console and printing out the input/output shapes. |
It is unclear from the documentation how to deny a registration request in Python. The elements used in the JavaScript example ( For Python, the lambda output must be the |
To do any kind of processing on the registration process, you will need to link lambda functions from the cognito triggers section in the user pool. You will find triggers for Pre sign-up , pre-authentication etc. import json
def lambda_handler(event, context):
ALLOWED_DOMAIN = "@cloudm.ca"
data = json.dumps(event)
y = json.loads(data)
email = y['request']['userAttributes']['email'] # this must be passed in the attributes from js client
domain = email[ email.find("@") : ]
if domain == ALLOWED_DOMAIN:
# enable below to bypass confirming email by the user
# which is not a good idea
#y['response']['autoConfirmUser'] = True
#y['response']['autoVerifyEmail'] = True
return y
else:
return None
return y; #must return this as this is a pipeline, the next process must get this |
@randhawp What is data here? Also, I get: expected string or buffer error when I run json.loads on event. |
data = json.dumps(event) |
How do you deny it? Just raise an exception?
And for it to succeed you just return the
|
return a None if it fails and if it succeeds then pass the event data. See example above. You can also use a post trigger to then handle the event data, for example adding it in your table for providing role based access to your application or some other custom logic. The important point is that the event data must be returned for the cognito pipeline to propagate to the the end. |
Did anyone get the pre-sgnup code in python working ?
I always get the error InvalidLambdaResponseException: Unrecognizable lambda output
Not able to figure out what the response should be.
Any pointers will be helpful
The text was updated successfully, but these errors were encountered: