aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/controller/visitor
diff options
context:
space:
mode:
Diffstat (limited to 'application/front/controller/visitor')
-rw-r--r--application/front/controller/visitor/LoginController.php2
-rw-r--r--application/front/controller/visitor/ShaarliVisitorController.php13
-rw-r--r--application/front/controller/visitor/TagController.php8
3 files changed, 19 insertions, 4 deletions
diff --git a/application/front/controller/visitor/LoginController.php b/application/front/controller/visitor/LoginController.php
index 4de2f55d..0db1f463 100644
--- a/application/front/controller/visitor/LoginController.php
+++ b/application/front/controller/visitor/LoginController.php
@@ -23,7 +23,7 @@ class LoginController extends ShaarliVisitorController
23 if ($this->container->loginManager->isLoggedIn() 23 if ($this->container->loginManager->isLoggedIn()
24 || $this->container->conf->get('security.open_shaarli', false) 24 || $this->container->conf->get('security.open_shaarli', false)
25 ) { 25 ) {
26 return $response->withRedirect('./'); 26 return $this->redirect($response, '/');
27 } 27 }
28 28
29 $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams()); 29 $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams());
diff --git a/application/front/controller/visitor/ShaarliVisitorController.php b/application/front/controller/visitor/ShaarliVisitorController.php
index b90b1e8f..b494a8e6 100644
--- a/application/front/controller/visitor/ShaarliVisitorController.php
+++ b/application/front/controller/visitor/ShaarliVisitorController.php
@@ -105,6 +105,19 @@ abstract class ShaarliVisitorController
105 } 105 }
106 106
107 /** 107 /**
108 * Simple helper which prepend the base path to redirect path.
109 *
110 * @param Response $response
111 * @param string $path Absolute path, e.g.: `/`, or `/admin/shaare/123` regardless of install directory
112 *
113 * @return Response updated
114 */
115 protected function redirect(Response $response, string $path): Response
116 {
117 return $response->withRedirect($this->container->basePath . $path);
118 }
119
120 /**
108 * Generates a redirection to the previous page, based on the HTTP_REFERER. 121 * Generates a redirection to the previous page, based on the HTTP_REFERER.
109 * It fails back to the home page. 122 * It fails back to the home page.
110 * 123 *
diff --git a/application/front/controller/visitor/TagController.php b/application/front/controller/visitor/TagController.php
index a0bc1d1b..c176f43f 100644
--- a/application/front/controller/visitor/TagController.php
+++ b/application/front/controller/visitor/TagController.php
@@ -11,6 +11,8 @@ use Slim\Http\Response;
11 * Class TagController 11 * Class TagController
12 * 12 *
13 * Slim controller handle tags. 13 * Slim controller handle tags.
14 *
15 * TODO: check redirections with new helper
14 */ 16 */
15class TagController extends ShaarliVisitorController 17class TagController extends ShaarliVisitorController
16{ 18{
@@ -27,10 +29,10 @@ class TagController extends ShaarliVisitorController
27 // In case browser does not send HTTP_REFERER, we search a single tag 29 // In case browser does not send HTTP_REFERER, we search a single tag
28 if (null === $referer) { 30 if (null === $referer) {
29 if (null !== $newTag) { 31 if (null !== $newTag) {
30 return $response->withRedirect('./?searchtags='. urlencode($newTag)); 32 return $this->redirect($response, '/?searchtags='. urlencode($newTag));
31 } 33 }
32 34
33 return $response->withRedirect('./'); 35 return $this->redirect($response, '/');
34 } 36 }
35 37
36 $currentUrl = parse_url($referer); 38 $currentUrl = parse_url($referer);
@@ -81,7 +83,7 @@ class TagController extends ShaarliVisitorController
81 83
82 // If the referrer is not provided, we can update the search, so we failback on the bookmark list 84 // If the referrer is not provided, we can update the search, so we failback on the bookmark list
83 if (empty($referer)) { 85 if (empty($referer)) {
84 return $response->withRedirect('./'); 86 return $this->redirect($response, '/');
85 } 87 }
86 88
87 $tagToRemove = $args['tag'] ?? null; 89 $tagToRemove = $args['tag'] ?? null;