diff options
-rw-r--r-- | application/legacy/LegacyController.php | 8 | ||||
-rw-r--r-- | tests/legacy/LegacyControllerTest.php | 6 |
2 files changed, 8 insertions, 6 deletions
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 | |||
42 | $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; | 42 | $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; |
43 | 43 | ||
44 | if (!$this->container->loginManager->isLoggedIn()) { | 44 | if (!$this->container->loginManager->isLoggedIn()) { |
45 | return $this->redirect($response, '/login' . $parameters); | 45 | return $this->redirect($response, '/login?returnurl=/admin/shaare' . $parameters); |
46 | } | 46 | } |
47 | 47 | ||
48 | return $this->redirect($response, '/admin/shaare' . $parameters); | 48 | return $this->redirect($response, '/admin/shaare' . $parameters); |
@@ -52,7 +52,7 @@ class LegacyController extends ShaarliVisitorController | |||
52 | protected function addlink(Request $request, Response $response): Response | 52 | protected function addlink(Request $request, Response $response): Response |
53 | { | 53 | { |
54 | if (!$this->container->loginManager->isLoggedIn()) { | 54 | if (!$this->container->loginManager->isLoggedIn()) { |
55 | return $this->redirect($response, '/login'); | 55 | return $this->redirect($response, '/login?returnurl=/admin/add-shaare'); |
56 | } | 56 | } |
57 | 57 | ||
58 | return $this->redirect($response, '/admin/add-shaare'); | 58 | return $this->redirect($response, '/admin/add-shaare'); |
@@ -61,7 +61,9 @@ class LegacyController extends ShaarliVisitorController | |||
61 | /** Legacy route: ?do=login */ | 61 | /** Legacy route: ?do=login */ |
62 | protected function login(Request $request, Response $response): Response | 62 | protected function login(Request $request, Response $response): Response |
63 | { | 63 | { |
64 | return $this->redirect($response, '/login'); | 64 | $returnurl = $request->getQueryParam('returnurl'); |
65 | |||
66 | return $this->redirect($response, '/login' . ($returnurl ? '?returnurl=' . $returnurl : '')); | ||
65 | } | 67 | } |
66 | 68 | ||
67 | /** Legacy route: ?do=logout */ | 69 | /** Legacy route: ?do=logout */ |
diff --git a/tests/legacy/LegacyControllerTest.php b/tests/legacy/LegacyControllerTest.php index 759a5b2a..460fbb3b 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', false], | 69 | ['post', [], '/login?returnurl=/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?title=test', false], | 71 | ['post', ['title' => 'test'], '/login?returnurl=/admin/shaare?title=test', false], |
72 | ['addlink', [], '/admin/add-shaare', true], | 72 | ['addlink', [], '/admin/add-shaare', true], |
73 | ['addlink', [], '/login', false], | 73 | ['addlink', [], '/login?returnurl=/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], |