From: ArthurHoaro Date: Tue, 1 Sep 2020 08:40:35 +0000 (+0200) Subject: Support redirection of legacy route 'do=configure' X-Git-Tag: v0.12.0-beta-1~30^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=11aa4a7a29c5a6358584ce0f63c061fdb0704b18;hp=9e2d47e519783a991962e1fe2c9f28d77756ae49;p=github%2Fshaarli%2FShaarli.git Support redirection of legacy route 'do=configure' --- 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], ]; } }