bubbl-oss / evoting

E-voting app for campuses, first in AUN
1 stars 2 forks source link

If there's no password, just take user straight to vote casting page #80

Open LeanKhan opened 3 years ago

AnointingMax commented 3 years ago

@LeanKhan I'm not really sure about how to do this. I don't know why this isn't working `if election.password == "" or election.password == None: res = make_response(redirect(url_for('election_vote', link=link))) res.set_cookie('evoting-user-can-vote', str(election.id), expires=int(datetime.timestamp(election.ending_at)))

    return res`
AnointingMax commented 3 years ago

` if election.password == "" or election.password == None: res = make_response(redirect(url_for('election_vote', link=link))) res.set_cookie('evoting-user-can-vote', str(election.id), expires=int(datetime.timestamp(election.ending_at)))

    return res

`

LeanKhan commented 3 years ago

Okay you want to set a cookie if there's no password for this election. A common issue I faced with setting cookies is the Expiring_at time. To delete a cookie from the backend you have to set that cookie's Expiring time to the past or 0. If you try to set a cookie with an expiring_at time in the past, the browser won't save it at all. So check the ending_at if the election and change it to a time in the future and try again.

LeanKhan commented 3 years ago

You can always see the cookie setting in action by looking at the network tab under devtools. After entering the password or navigating to the voting page, check the request for that page in the Nerworks tab. You should see under "Response" a header passed called "set-cookie" this is what tells your browser to create a cookie. Check it out