Anonymous users - Multiple voting from one IP

Created on 19 September 2017, over 7 years ago
Updated 18 January 2023, almost 2 years ago

Problem/Motivation

Currently, the poll module allows only one anonymous vote for a poll per IP address. There are use cases where this restriction isn't desired. For example when a group of people, who are on the same network, are asked to vote on the poll.

Steps to reproduce

  1. Create a poll.
  2. Log out.
  3. Place a vote on the poll.
  4. Open an other browser or go to the poll with an other device.

You see only the poll results and cannot vote again.

Proposed resolution

On the poll creation form, add an option to change the restriction mode for anonymous users.

Allow the following restriction methods:

  • One vote per IP
    This is the default option and follows the current behavior. If an anonymous user places a vote, he/she cannot vote again: not in an other browser, not when clearing cookies and not even on an other device in the same network. He/she can however place another vote when switching his/her device to an other network.
  • One vote per session
    When an anonymous user places a vote, he/she cannot vote again during the current session. He/she can vote again when using an other browser, when clearing cookies or when using an other device in the same network. He/she can't however place another vote when only switching networks.
  • Unlimited votes
    There are no restrictions on how many votes the same anonymous user can place. After voting, he/she can go back to the voting form to place another vote. Can be useful in a situation where a group of people need to place a vote on the same device, for example at a stand in an exhibition hall.
    This option has no effect on authenticated users, they continue to only be able to vote once per poll.

Remaining tasks

  • Fix the test failures for the vote restriction option "unlimited".
  • Review

User interface changes

On the poll creation form, a setting called "Anonymous vote restriction" is added. This setting is only visible when enabling the option "Allow anonymous votes".

API changes

  • Constants are added to PollInterface for each vote restriction.
  • A method called getVoteRestriction() is added to PollInterface.
  • When calling the method saveVote() on PollVoteStorage, the ID of the saved vote gets returned. Previously, the method returned nothing.

Data model changes

  • The table "poll_vote" gets a new column called "id". This also becomes the new primary key. This is needed because multiple votes can now exist per combination of poll ID, user ID and hostname (which previously formed the primary key).
  • The content entity type "poll" gets a new base field called "anonymous_vote_restriction". In this field, the setting for the vote restriction is stored.

Release notes snippet

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇦Ukraine stomusic Ukraine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024