Skip to content

Commit

Permalink
Update contact form and newsletter handlers to check http method.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenchio committed Jan 15, 2025
1 parent 91e7d15 commit 38e3ec8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lambda-functions/contact_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ def send_email(event_body):


def handle_contact_form(event, context):
if event['requestContext']['http']['method'] != 'POST':
return {
'statusCode': 400,
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps({
'success': False,
'message': 'Unsupported http method'
})
}

if event['body']:
try:
body = json.loads(event['body'])
Expand Down
12 changes: 12 additions & 0 deletions lambda-functions/newsletter_sign_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ def add_crisp_contact(email):


def handle_newsletter_sign_up(event, context):
if event['requestContext']['http']['method'] != 'POST':
return {
'statusCode': 400,
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps({
'success': False,
'message': 'Unsupported http method'
})
}

if event['body']:
try:
body = json.loads(event['body'])
Expand Down

0 comments on commit 38e3ec8

Please sign in to comment.