aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/legacy/LegacyController.php15
-rw-r--r--tests/legacy/LegacyControllerTest.php6
2 files changed, 12 insertions, 9 deletions
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
40 public function post(Request $request, Response $response): Response 40 public function post(Request $request, Response $response): Response
41 { 41 {
42 $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; 42 $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : '';
43 $route = '/admin/shaare';
43 44
44 if (!$this->container->loginManager->isLoggedIn()) { 45 if (!$this->container->loginManager->isLoggedIn()) {
45 return $this->redirect($response, '/login?returnurl=/admin/shaare' . $parameters); 46 return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters);
46 } 47 }
47 48
48 return $this->redirect($response, '/admin/shaare' . $parameters); 49 return $this->redirect($response, $route . $parameters);
49 } 50 }
50 51
51 /** Legacy route: ?addlink= */ 52 /** Legacy route: ?addlink= */
52 protected function addlink(Request $request, Response $response): Response 53 protected function addlink(Request $request, Response $response): Response
53 { 54 {
55 $route = '/admin/add-shaare';
56
54 if (!$this->container->loginManager->isLoggedIn()) { 57 if (!$this->container->loginManager->isLoggedIn()) {
55 return $this->redirect($response, '/login?returnurl=/admin/add-shaare'); 58 return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route);
56 } 59 }
57 60
58 return $this->redirect($response, '/admin/add-shaare'); 61 return $this->redirect($response, $route);
59 } 62 }
60 63
61 /** Legacy route: ?do=login */ 64 /** Legacy route: ?do=login */
62 protected function login(Request $request, Response $response): Response 65 protected function login(Request $request, Response $response): Response
63 { 66 {
64 $returnurl = $request->getQueryParam('returnurl'); 67 $returnUrl = $request->getQueryParam('returnurl');
65 68
66 return $this->redirect($response, '/login' . ($returnurl ? '?returnurl=' . $returnurl : '')); 69 return $this->redirect($response, '/login' . ($returnUrl ? '?returnurl=' . $returnUrl : ''));
67 } 70 }
68 71
69 /** Legacy route: ?do=logout */ 72 /** Legacy route: ?do=logout */
diff --git a/tests/legacy/LegacyControllerTest.php b/tests/legacy/LegacyControllerTest.php
index 460fbb3b..2bbbb1d7 100644
--- a/tests/legacy/LegacyControllerTest.php
+++ b/tests/legacy/LegacyControllerTest.php
@@ -66,11 +66,11 @@ class LegacyControllerTest extends TestCase
66 { 66 {
67 return [ 67 return [
68 ['post', [], '/admin/shaare', true], 68 ['post', [], '/admin/shaare', true],
69 ['post', [], '/login?returnurl=/admin/shaare', false], 69 ['post', [], '/login?returnurl=/subfolder/admin/shaare', false],
70 ['post', ['title' => 'test'], '/admin/shaare?title=test', true], 70 ['post', ['title' => 'test'], '/admin/shaare?title=test', true],
71 ['post', ['title' => 'test'], '/login?returnurl=/admin/shaare?title=test', false], 71 ['post', ['title' => 'test'], '/login?returnurl=/subfolder/admin/shaare?title=test', false],
72 ['addlink', [], '/admin/add-shaare', true], 72 ['addlink', [], '/admin/add-shaare', true],
73 ['addlink', [], '/login?returnurl=/admin/add-shaare', false], 73 ['addlink', [], '/login?returnurl=/subfolder/admin/add-shaare', false],
74 ['login', [], '/login', true], 74 ['login', [], '/login', true],
75 ['login', [], '/login', false], 75 ['login', [], '/login', false],
76 ['logout', [], '/admin/logout', true], 76 ['logout', [], '/admin/logout', true],