Search code examples
node.jshtmlweb-applicationsredisvote

how to "dont vote twice" mechanism


I was thinking of creating a voting app. The general idea is

  • browse a gallery
  • an awesome pic grabs your attention
  • hit the vote button underneath it
  • code magic happens
  • vote is counted
  • at a certain date, vote buttons become non-active and the app counts the votes

This will be a web app, which means html5-css3-express.js-redis framework, or something similar.

How can I ensure that the user cannot vote for the same pic twice? By making him sign up? Huge procedure for just a voting app, dont you think? Plus, I guess I will also need a CAPTCHA thing to avoid unwanted, mass sign up.

But if I use coockies of HTML5 local Storage API, what is stopping the same user to clear his/her coockies and vote for the same pic again and again?

What is the best method?

Thanks alot


Solution

  • The most secure way is by using accounts to keep track of who has voted. Accounts are easy to implement in your application and you don't even need to hold the account data yourself if you use a service like Passport.js. You'll likely have a database set up already which makes it easy to keep account data as well.

    The other method is to keep track of IP addresses but this has some issues (say, if a user uses a proxy). Also an IP address will cover all clients on a network means if one person votes on an image, all others will be unable to afterwards.