View Issue Details

This issue affects 2 person(s).
 12
IDProjectCategoryView StatusLast Update
19586Feature requestsUsability/user experiencepublic2026-10-26 14:37
Reportermfavetti Assigned To 
PrioritynoneSeverity@50@ 
Status newResolutionopen 
Summary19586: When using a survey alias, path based routing paramaters are not passed to the controller
Description

@efornasier noted that

limesurvey/<ALIAS>?token=<TOKEN> works

but

limesurvey/<ALIAS>/<TOKEN>
limesurvey/<ALIAS>/token/<TOKEN>

do not work

We could make both work

Currently all of the above get mapped to survey/index/sid/<SID>, with <SID> being looked up from alias (Also lang is set based on which language has the alias for the survey if not already set on $_GET)

A generic solution that passes key/value pairs of path based variables to the controller (either by adding back to controller route directly like /survey/index/sid/<SID>/key/value, or setting on $_GET, like $_GET[key] = value) would handle newtest/Y, token/<TOKEN>, etc.

Then there could be a special case of only two path components limesurvey/<ALIAS>/<TOKEN> and set token only (either on controller route or on $_GET like above)

this function is responsible: https://github.com/LimeSurvey/LimeSurvey/blob/a681a80e8036fe18d79731b5fbded44a77edaf66/application/core/LSYii_Application.php#L535

Steps To Reproduce

Steps to reproduce

Create a survey with an alias
Activate survey
Enable closed access
Add a dummy participant
Try the URLs above with the dummy participant token

Expected result

Survey loads for token automatically

Actual result

Survey loads and requests token entry

TagsNo tags attached.
Bug heat12
Git branch / Pull Request URLN/A
Users affected %

Users monitoring this issue

DenisChenu

Activities

mfavetti

mfavetti

2024-06-06 00:58

developer   ~80221

rough idea of where/what to implement, unfinished

aliastoken.patch (1,616 bytes)   
diff --git a/application/core/LSYii_Application.php b/application/core/LSYii_Application.php
index f816fe17..9e91fb1f 100755
--- a/application/core/LSYii_Application.php
+++ b/application/core/LSYii_Application.php
@@ -535,7 +535,8 @@ class LSYii_Application extends CWebApplication
     private function createControllerFromShortUrl($route)
     {
         $route = ltrim($route, "/");
-        $alias = explode("/", $route)[0];
+        $parts = explode("/", $route);
+        $alias = $parts[0];
         if (empty($alias)) {
             return null;
         }
@@ -563,7 +564,32 @@ class LSYii_Application extends CWebApplication
         if (empty($language)) {
             $_GET['lang'] = $languageSettings->surveyls_language;
         }
-        return parent::createController("survey/index/sid/" . $languageSettings->surveyls_survey_id);
+
+        $extra = '';
+
+        if(count($parts) > 1) {
+
+            if(count($parts) === 2) {
+                // $extra .= "/token/{$parts[1]}";
+                $_GET['token'] = $parts[1];
+            }
+            else {
+
+                for($i = 1; $i < count($parts); $i++) {
+                    if($parts[$i] === 'token') {
+                        // $extra .= "/token/{$parts[$i+1]}";
+                        $_GET['token'] = $parts[$i+1];
+                        $i++;
+                    }
+                }
+            }
+        }
+
+        echo "<pre>";
+        var_dump($extra);
+        echo "</pre>";
+
+        return parent::createController("survey/index/sid/" . $languageSettings->surveyls_survey_id . $extra);
     }
 
     /**
aliastoken.patch (1,616 bytes)   
DenisChenu

DenisChenu

2024-06-06 10:25

developer   ~80223

You can create your rough idea on github ?
No need PR for starting

Issue History

Date Modified Username Field Change
2024-06-06 00:27 mfavetti New Issue
2024-06-06 00:58 mfavetti Note Added: 80221
2024-06-06 00:58 mfavetti File Added: aliastoken.patch
2024-06-06 00:58 mfavetti Bug heat 0 => 2
2024-06-06 10:25 DenisChenu Issue Monitored: DenisChenu
2024-06-06 10:25 DenisChenu Bug heat 2 => 4
2024-06-06 10:25 DenisChenu Note Added: 80223
2024-06-06 10:25 DenisChenu Bug heat 4 => 6
2024-09-02 09:32 Mazi Bug heat 6 => 12
2026-10-26 14:37 c_schmitz Project Bug reports => Feature requests