SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit aad3bc60 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add request.META to error mail

parent bef2f763
No related branches found
No related tags found
No related merge requests found
import logging
import json
from django.utils import timezone
from django.shortcuts import get_object_or_404, render
......@@ -1328,15 +1328,21 @@ def csrf_failure(request, reason=""):
Custom CRSF Failure. Informing admins via email as well.
"""
# Filter out privacy data
settings_dict = {}
post_data = {}
for key in request.POST.keys():
if key:
settings_dict[key] = cleanse_setting(key, request.POST[key])
post_data[key] = cleanse_setting(key, request.POST[key])
# Email content
body = 'Error message: ' + reason + '\nUser: ' + str(request.user)
body += '\nRequest GET: ' + str(request.GET) + '\nRequest POST: '
body += str(settings_dict)
body = {
'ERROR': str(reason),
'USER': str(request.user),
'GET': dict(request.GET),
'POST': post_data,
'META': {k: str(v) for k, v in request.META.items()},
}
body = json.dumps(body, indent=4)
mail.mail_admins('CRSF Failure', body)
return render(request, 'crsf-failure.html')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment