View Issue Details

This bug affects 1 person(s).
 12
IDProjectCategoryView StatusLast Update
16538Bug reportsRemoteControlpublic2020-08-26 09:36
ReporterTonyMonast Assigned Togabrieljenik  
PriorityhighSeverityminor 
Status closedResolutionfixed 
Product Version4.3.5 
Summary16538: Can add 2 survey participantes with the same token with the RPC api
Description

The JSON_RPC api let you create two participants with the same token.

Problems :

  1. Inconsistency with the UI which does not allow to create two participants with the same token
  2. Cannot edit participants unless we change their token
  3. May see the first name and last name of the other candidate in the survey template
  4. When a candidate completes the survey, Remaining uses and Completed don't change.
Steps To Reproduce
  1. Call add_participants with the JSON_RPC api to add the first participant with the token 1234567890
  2. Call add_participants with the JSON_RPC api to add the second participant with the token 1234567890
  3. Go to the participants screen of the survey
TagsNo tags attached.
Attached Files
participants.png (6,503 bytes)   
participants.png (6,503 bytes)   
Bug heat12
Complete LimeSurvey version number (& build)Version 4.3.5+200721
I will donate to the project if issue is resolvedNo
Browser
Database type & versionmysql 5.7.31
Server OS (if known)
Webserver software & version (if known)
PHP Version 7.4.8

Users monitoring this issue

TonyMonast

Activities

Mazi

Mazi

2020-08-03 12:55

updater   ~59264

@cdorin, when a developer is looking into this, please also make sure to check the LS3 code base. My guess is that the same issue exists there as well.

Mazi

Mazi

2020-08-03 17:44

updater   ~59273

@TonyMonast, we noted that the same also applies to email addresses (tested with Limesurvey 3.22.27). Usually Limesurvey doesn't allow the same email address for multiple entries at the participant table. But using the API there seems to be no warning or the like. Can you confirm this?

@DenisChenu, what do you think is the best way to deal with this? I think similar to the admin features, the API should throw errors if duplicate tokens or emails are added. In addition we could add additional parameters for enabling/disabling filters for duplicate tokens/emails/..., what do you think?

TonyMonast

TonyMonast

2020-08-03 17:58

reporter   ~59274

@Mazi, I confirm that I am able to create two participants with the same email with the JSON_RPC API. You suggested "In addition we could add additional parameters for enabling/disabling filters for duplicate tokens/emails/", do you mean a parameter to allow duplicate entry (email and token) like I'm able to create? If so, note that when there is a duplicate token in the participants list, it causes other bugs like the ones I mentioned. The system assumes that the participant token is unique, and if you allow having a duplicate token, I suppose you will have to change a lot of code to support this.

DenisChenu

DenisChenu

2020-08-03 19:48

developer   ~59275

The JSON_RPC api let you create two participants with the same token.

Exactly the same ? Are you sure you don't have a space ?
See https://github.com/LimeSurvey/LimeSurvey/blob/100f7ffa44d350649074080d33ecddadaa23042d/application/models/Token.php#L366

  1. API must validate token
  2. Allow multiple with option (like GUI) for email

@Mazi : email adress are not a issue , token are an issue … email adress is a misfeature … (and need a separate mantis number)

DenisChenu

DenisChenu

2020-08-03 19:49

developer   ~59276

Last edited: 2020-08-03 19:49

  1. token : duplicate MUST be disallowed : always . It's a big issue.
  2. email : it's a featuire request, need to be allowed.
TonyMonast

TonyMonast

2020-08-03 20:01

reporter   ~59277

@DenisChenu Yes, exactly the same token, no space. See the new screenshot.

duplicate-tokens.png (7,667 bytes)   
duplicate-tokens.png (7,667 bytes)   
TonyMonast

TonyMonast

2020-08-03 20:03

reporter   ~59278

@DenisChenu,

To reproduce that, you need to do 2 separates calls to the api.

DenisChenu

DenisChenu

2020-08-03 21:04

developer   ~59279

OK:
3.X version : use save() : no way to add token with same code https://github.com/LimeSurvey/LimeSurvey/blob/1ae7e788a9f67c355a884c1fe4b0eb66c43f78da/application/helpers/remotecontrol/remotecontrol_handle.php#L1765
4.X version $token->encryptSave() https://github.com/LimeSurvey/LimeSurvey/blob/100f7ffa44d350649074080d33ecddadaa23042d/application/helpers/remotecontrol/remotecontrol_handle.php#L1812, way to add same code

encryptsave don't validate … https://github.com/LimeSurvey/LimeSurvey/blob/100f7ffa44d350649074080d33ecddadaa23042d/application/models/LSActiveRecord.php#L390

gabrieljenik

gabrieljenik

2020-08-05 00:13

manager   ~59310

Last edited: 2020-08-05 00:13

Adding validation to the save operation.

What I have seen is that encryptSave doesn't do validation by default.
I haven't updated that, but shouldn't we? Why it was set to false?

PR: https://github.com/LimeSurvey/LimeSurvey/pull/1534

gabrieljenik

gabrieljenik

2020-08-20 00:43

manager   ~59537

Uploaded unit test.

Also it is to notice we should, on another story, turn validation = TRUE for the encryptSave.
Also, we could enhance this is with some kind of attribute which tells if the token is encrypted or not as to not double encrpyt or not double decrypt.

TonyMonast

TonyMonast

2020-08-24 19:37

reporter   ~59597

When do you plan to merge the code to release a new version that fixes this bug? Currently I either have to modify the code of our LimeSurvey installations or make my application handles duplicates and not LimeSurvey, which makes the code over-complicated for nothing.

Thank you!

gabrieljenik

gabrieljenik

2020-08-25 11:36

manager   ~59602

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=30419

lime_release_bot

lime_release_bot

2020-08-26 09:36

administrator   ~59614

Fixed in Release 4.3.14+200826

Related Changesets

LimeSurvey: master b11095ae

2020-08-05 00:09:14

gabrieljenik

Details Diff
Fixed issue 16538: Can add 2 survey participantes with the same token with the RPC api

Adding validation to the save operation
Affected Issues
16538
mod - application/helpers/remotecontrol/remotecontrol_handle.php Diff File

LimeSurvey: master e17c8179

2020-08-20 00:39:27

gabrieljenik

Details Diff
Fixed issue 16538: Can add 2 survey participantes with the same token with the RPC api

Encrypt and validation unit test
Affected Issues
16538
mod - tests/unit/models/EncryptAttributesTest.php Diff File

LimeSurvey: master 4613f217

2020-08-24 21:26:09

gabrieljenik

Details Diff
Fixed issue 16538: Can add 2 survey participantes with the same token with the RPC api

testAddParticipants remote control unit test
Affected Issues
16538
mod - tests/unit/helpers/RemoteControlTest.php Diff File

LimeSurvey: master 6d63d832

2020-08-25 11:36:41

ollehar1


Committer: GitHub Details Diff
Fixed issue 16538: Can add 2 survey participantes with the same token with the RPC api Affected Issues
16538
mod - application/helpers/remotecontrol/remotecontrol_handle.php Diff File
mod - tests/unit/helpers/RemoteControlTest.php Diff File
mod - tests/unit/models/EncryptAttributesTest.php Diff File

Issue History

Date Modified Username Field Change
2020-07-29 17:40 TonyMonast New Issue
2020-07-29 17:40 TonyMonast File Added: participants.png
2020-07-29 19:17 TonyMonast Issue Monitored: TonyMonast
2020-07-29 20:05 cdorin Priority none => high
2020-07-29 20:05 cdorin Status new => confirmed
2020-07-29 20:05 cdorin Zoho Sprints => |Yes|
2020-07-29 20:05 swendrich Zoho Sprints ID => 14469000000197013
2020-08-03 12:55 Mazi Note Added: 59264
2020-08-03 17:44 Mazi Note Added: 59273
2020-08-03 17:58 TonyMonast Note Added: 59274
2020-08-03 19:48 DenisChenu Note Added: 59275
2020-08-03 19:49 DenisChenu Note Added: 59276
2020-08-03 19:49 DenisChenu Note Edited: 59276
2020-08-03 20:01 TonyMonast Note Added: 59277
2020-08-03 20:01 TonyMonast File Added: duplicate-tokens.png
2020-08-03 20:03 TonyMonast Note Added: 59278
2020-08-03 21:04 DenisChenu Note Added: 59279
2020-08-05 00:13 gabrieljenik Note Added: 59310
2020-08-05 00:13 gabrieljenik Note Edited: 59310
2020-08-20 00:43 gabrieljenik Note Added: 59537
2020-08-24 19:37 TonyMonast Note Added: 59597
2020-08-25 11:36 ollehar1 Changeset attached => LimeSurvey master 6d63d832
2020-08-25 11:36 gabrieljenik Changeset attached => LimeSurvey master 4613f217
2020-08-25 11:36 gabrieljenik Changeset attached => LimeSurvey master e17c8179
2020-08-25 11:36 gabrieljenik Changeset attached => LimeSurvey master b11095ae
2020-08-25 11:36 gabrieljenik Note Added: 59602
2020-08-25 11:36 gabrieljenik Assigned To => gabrieljenik
2020-08-25 11:36 gabrieljenik Resolution open => fixed
2020-08-26 09:36 lime_release_bot Zoho Sprints Yes => |Yes|
2020-08-26 09:36 lime_release_bot Note Added: 59614
2020-08-26 09:36 lime_release_bot Status confirmed => closed
2021-08-03 04:34 guest Bug heat 10 => 12