]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Support redirection of legacy route 'do=configure' 1534/head
authorArthurHoaro <arthur@hoa.ro>
Tue, 1 Sep 2020 08:40:35 +0000 (10:40 +0200)
committerArthurHoaro <arthur@hoa.ro>
Tue, 1 Sep 2020 08:40:35 +0000 (10:40 +0200)
application/legacy/LegacyController.php
tests/legacy/LegacyControllerTest.php

index 75fa9d2cfb962cf1009bea63da16ed0d41a74c93..e16dd0f43effa6921b6238f0546e7357c9cea188 100644 (file)
@@ -132,4 +132,21 @@ class LegacyController extends ShaarliVisitorController
 
         return $this->redirect($response, '/feed/' . $feedType . $parameters);
     }
+
+    /** Legacy route: ?do=configure */
+    protected function configure(Request $request, Response $response): Response
+    {
+        $route = '/admin/configure';
+
+        if (!$this->container->loginManager->isLoggedIn()) {
+            return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route);
+        }
+
+        return $this->redirect($response, $route);
+    }
+
+    protected function getBasePath(): string
+    {
+        return $this->container->basePath ?: '';
+    }
 }
index 2bbbb1d761cbc36cb2741c083ef184948d098e22..4e52f3e186597375b351d575c1067b9a7dbd7573 100644 (file)
@@ -94,6 +94,8 @@ class LegacyControllerTest extends TestCase
             ['opensearch', [], '/open-search', true],
             ['dailyrss', [], '/daily-rss', false],
             ['dailyrss', [], '/daily-rss', true],
+            ['configure', [], '/login?returnurl=/subfolder/admin/configure', false],
+            ['configure', [], '/admin/configure', true],
         ];
     }
 }