diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-01 10:40:18 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-09-01 10:40:18 +0200 |
commit | 9e2d47e519783a991962e1fe2c9f28d77756ae49 (patch) | |
tree | d3768633982577813e55ecb651084a0a3a5e6693 /application/legacy/LegacyController.php | |
parent | aca995e09cf9c210ffe45584fbe50dcedb8bdebb (diff) | |
download | Shaarli-9e2d47e519783a991962e1fe2c9f28d77756ae49.tar.gz Shaarli-9e2d47e519783a991962e1fe2c9f28d77756ae49.tar.zst Shaarli-9e2d47e519783a991962e1fe2c9f28d77756ae49.zip |
Fix legacy redirection when Shaarli instance is under a subfolder
Diffstat (limited to 'application/legacy/LegacyController.php')
-rw-r--r-- | application/legacy/LegacyController.php | 15 |
1 files changed, 9 insertions, 6 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 */ |