If cookie value already exists, then don't let a vote happen

This commit is contained in:
Jonathan Ervine 2020-11-25 22:07:24 +08:00
parent b790b733ea
commit f9aa709a4b

View File

@ -236,6 +236,9 @@ def hkfcD_vote_thanks():
if _motm and _dotd and request.method == 'POST': if _motm and _dotd and request.method == 'POST':
prev_identity = request.cookies.get('sessionID') prev_identity = request.cookies.get('sessionID')
warn(prev_identity) warn(prev_identity)
if prev_identity:
warn("Naughty, naughty, you've already voted!")
else:
identity = randomUrlSuffix(8) identity = randomUrlSuffix(8)
id_commit = "INSERT INTO motmSessions (sessionID) VALUES ('" + identity + "')" id_commit = "INSERT INTO motmSessions (sessionID) VALUES ('" + identity + "')"
sql_write(id_commit) sql_write(id_commit)
@ -246,7 +249,7 @@ def hkfcD_vote_thanks():
elif _comments == "Optional comments added here": elif _comments == "Optional comments added here":
print("No comment") print("No comment")
else: else:
### The matchDate has been replaced with the matchNumber - this should be corrected at some point (via a fixture table lookup) ### The matchDate has been replaced with the matchNumber - this should be corrected at some point (via a fixture table lookup)
sql3 = "INSERT INTO _motmComments (_matchDate, opposition, comment) VALUES ('" + _matchDate + "', '" + _oppo + "', '" + _fixed_comments + "')" sql3 = "INSERT INTO _motmComments (_matchDate, opposition, comment) VALUES ('" + _matchDate + "', '" + _oppo + "', '" + _fixed_comments + "')"
#sql_write(sql3) #sql_write(sql3)
#sql_write(sql) #sql_write(sql)