diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-03 08:35:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 08:35:05 +0200 |
commit | d95624add466d6ee5335e60901c014275134f383 (patch) | |
tree | 4c4a7f9eaf85ce51a7a42ca7e6dc139d2e5edc84 /application | |
parent | 43582975dcef7ba0a47d740f29f925d02a067849 (diff) | |
parent | 11aa4a7a29c5a6358584ce0f63c061fdb0704b18 (diff) | |
download | Shaarli-d95624add466d6ee5335e60901c014275134f383.tar.gz Shaarli-d95624add466d6ee5335e60901c014275134f383.tar.zst Shaarli-d95624add466d6ee5335e60901c014275134f383.zip |
Merge pull request #1534 from ArthurHoaro/fix/legacy-route-post
Diffstat (limited to 'application')
-rw-r--r-- | application/legacy/LegacyController.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php index 26465d2c..e16dd0f4 100644 --- a/application/legacy/LegacyController.php +++ b/application/legacy/LegacyController.php | |||
@@ -40,28 +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' . $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'); | 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 | return $this->redirect($response, '/login'); | 67 | $returnUrl = $request->getQueryParam('returnurl'); |
68 | |||
69 | return $this->redirect($response, '/login' . ($returnUrl ? '?returnurl=' . $returnUrl : '')); | ||
65 | } | 70 | } |
66 | 71 | ||
67 | /** Legacy route: ?do=logout */ | 72 | /** Legacy route: ?do=logout */ |
@@ -127,4 +132,21 @@ class LegacyController extends ShaarliVisitorController | |||
127 | 132 | ||
128 | return $this->redirect($response, '/feed/' . $feedType . $parameters); | 133 | return $this->redirect($response, '/feed/' . $feedType . $parameters); |
129 | } | 134 | } |
135 | |||
136 | /** Legacy route: ?do=configure */ | ||
137 | protected function configure(Request $request, Response $response): Response | ||
138 | { | ||
139 | $route = '/admin/configure'; | ||
140 | |||
141 | if (!$this->container->loginManager->isLoggedIn()) { | ||
142 | return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route); | ||
143 | } | ||
144 | |||
145 | return $this->redirect($response, $route); | ||
146 | } | ||
147 | |||
148 | protected function getBasePath(): string | ||
149 | { | ||
150 | return $this->container->basePath ?: ''; | ||
151 | } | ||
130 | } | 152 | } |