From 11aa4a7a29c5a6358584ce0f63c061fdb0704b18 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 1 Sep 2020 10:40:35 +0200 Subject: [PATCH 1/1] Support redirection of legacy route 'do=configure' --- application/legacy/LegacyController.php | 17 +++++++++++++++++ tests/legacy/LegacyControllerTest.php | 2 ++ 2 files changed, 19 insertions(+) diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php index 75fa9d2c..e16dd0f4 100644 --- a/application/legacy/LegacyController.php +++ b/application/legacy/LegacyController.php @@ -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 ?: ''; + } } diff --git a/tests/legacy/LegacyControllerTest.php b/tests/legacy/LegacyControllerTest.php index 2bbbb1d7..4e52f3e1 100644 --- a/tests/legacy/LegacyControllerTest.php +++ b/tests/legacy/LegacyControllerTest.php @@ -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], ]; } } -- 2.41.0