Skip to content
Snippets Groups Projects
Commit 8e0eb848 authored by Shirlei Chaves's avatar Shirlei Chaves
Browse files

Save cast_ip

parent feac15e4
No related branches found
No related tags found
No related merge requests found
......@@ -616,12 +616,22 @@ def one_election_cast_confirm(request, election):
if voter:
vote = datatypes.LDObject.fromDict(utils.from_json(encrypted_vote), type_hint='legacy/EncryptedVote').wrapped_obj
if 'HTTP_X_FORWARDED_FOR' in request.META:
# HTTP_X_FORWARDED_FOR sometimes have a comma delimited list of IP addresses
# Here we want the originating IP address
# See http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/x-forwarded-headers.html
# and https://en.wikipedia.org/wiki/X-Forwarded-For
cast_ip = request.META.get('HTTP_X_FORWARDED_FOR').split(',')[0].strip() or None
else:
cast_ip = request.META.get('REMOTE_ADDR', None)
# prepare the vote to cast
cast_vote_params = {
'vote' : vote,
'voter' : voter,
'vote_hash': vote_fingerprint,
'cast_at': datetime.datetime.utcnow()
'cast_at': datetime.datetime.utcnow(),
'cast_ip': cast_ip
}
cast_vote = CastVote(**cast_vote_params)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment