From aca995e09cf9c210ffe45584fbe50dcedb8bdebb Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 1 Sep 2020 10:12:54 +0200 Subject: Fix support for legacy route login redirection Makes sure that the user is properly redirected to the bookmark form after login, even with legacy routes --- application/legacy/LegacyController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'application/legacy/LegacyController.php') diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php index 26465d2c..efc14409 100644 --- a/application/legacy/LegacyController.php +++ b/application/legacy/LegacyController.php @@ -42,7 +42,7 @@ class LegacyController extends ShaarliVisitorController $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; if (!$this->container->loginManager->isLoggedIn()) { - return $this->redirect($response, '/login' . $parameters); + return $this->redirect($response, '/login?returnurl=/admin/shaare' . $parameters); } return $this->redirect($response, '/admin/shaare' . $parameters); @@ -52,7 +52,7 @@ class LegacyController extends ShaarliVisitorController protected function addlink(Request $request, Response $response): Response { if (!$this->container->loginManager->isLoggedIn()) { - return $this->redirect($response, '/login'); + return $this->redirect($response, '/login?returnurl=/admin/add-shaare'); } return $this->redirect($response, '/admin/add-shaare'); @@ -61,7 +61,9 @@ class LegacyController extends ShaarliVisitorController /** Legacy route: ?do=login */ protected function login(Request $request, Response $response): Response { - return $this->redirect($response, '/login'); + $returnurl = $request->getQueryParam('returnurl'); + + return $this->redirect($response, '/login' . ($returnurl ? '?returnurl=' . $returnurl : '')); } /** Legacy route: ?do=logout */ -- cgit v1.2.3 From 9e2d47e519783a991962e1fe2c9f28d77756ae49 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 1 Sep 2020 10:40:18 +0200 Subject: Fix legacy redirection when Shaarli instance is under a subfolder --- application/legacy/LegacyController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'application/legacy/LegacyController.php') diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php index efc14409..75fa9d2c 100644 --- a/application/legacy/LegacyController.php +++ b/application/legacy/LegacyController.php @@ -40,30 +40,33 @@ class LegacyController extends ShaarliVisitorController public function post(Request $request, Response $response): Response { $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; + $route = '/admin/shaare'; if (!$this->container->loginManager->isLoggedIn()) { - return $this->redirect($response, '/login?returnurl=/admin/shaare' . $parameters); + return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters); } - return $this->redirect($response, '/admin/shaare' . $parameters); + return $this->redirect($response, $route . $parameters); } /** Legacy route: ?addlink= */ protected function addlink(Request $request, Response $response): Response { + $route = '/admin/add-shaare'; + if (!$this->container->loginManager->isLoggedIn()) { - return $this->redirect($response, '/login?returnurl=/admin/add-shaare'); + return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route); } - return $this->redirect($response, '/admin/add-shaare'); + return $this->redirect($response, $route); } /** Legacy route: ?do=login */ protected function login(Request $request, Response $response): Response { - $returnurl = $request->getQueryParam('returnurl'); + $returnUrl = $request->getQueryParam('returnurl'); - return $this->redirect($response, '/login' . ($returnurl ? '?returnurl=' . $returnurl : '')); + return $this->redirect($response, '/login' . ($returnUrl ? '?returnurl=' . $returnUrl : '')); } /** Legacy route: ?do=logout */ -- cgit v1.2.3 From 11aa4a7a29c5a6358584ce0f63c061fdb0704b18 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 1 Sep 2020 10:40:35 +0200 Subject: Support redirection of legacy route 'do=configure' --- application/legacy/LegacyController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'application/legacy/LegacyController.php') 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 ?: ''; + } } -- cgit v1.2.3