diff options
Diffstat (limited to 'application/legacy')
-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 | } |