aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/ShaarliMiddleware.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-05-22 13:20:31 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commit2899ebb5b5e82890c877151f5c02045266ac9973 (patch)
tree0c4e2684c7f6d161f92a21181bfa4b2f78d6a82f /application/front/ShaarliMiddleware.php
parentaf290059d10319e76d1e7d78b592cab99c26d91a (diff)
downloadShaarli-2899ebb5b5e82890c877151f5c02045266ac9973.tar.gz
Shaarli-2899ebb5b5e82890c877151f5c02045266ac9973.tar.zst
Shaarli-2899ebb5b5e82890c877151f5c02045266ac9973.zip
Initialize admin Slim controllers
- Reorganize visitor controllers - Fix redirection with Slim's requests base path - Fix daily links
Diffstat (limited to 'application/front/ShaarliMiddleware.php')
-rw-r--r--application/front/ShaarliMiddleware.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php
index fa6c6467..f8992e0b 100644
--- a/application/front/ShaarliMiddleware.php
+++ b/application/front/ShaarliMiddleware.php
@@ -3,7 +3,8 @@
3namespace Shaarli\Front; 3namespace Shaarli\Front;
4 4
5use Shaarli\Container\ShaarliContainer; 5use Shaarli\Container\ShaarliContainer;
6use Shaarli\Front\Exception\ShaarliException; 6use Shaarli\Front\Exception\ShaarliFrontException;
7use Shaarli\Front\Exception\UnauthorizedException;
7use Slim\Http\Request; 8use Slim\Http\Request;
8use Slim\Http\Response; 9use Slim\Http\Response;
9 10
@@ -39,7 +40,7 @@ class ShaarliMiddleware
39 { 40 {
40 try { 41 try {
41 $response = $next($request, $response); 42 $response = $next($request, $response);
42 } catch (ShaarliException $e) { 43 } catch (ShaarliFrontException $e) {
43 $this->container->pageBuilder->assign('message', $e->getMessage()); 44 $this->container->pageBuilder->assign('message', $e->getMessage());
44 if ($this->container->conf->get('dev.debug', false)) { 45 if ($this->container->conf->get('dev.debug', false)) {
45 $this->container->pageBuilder->assign( 46 $this->container->pageBuilder->assign(
@@ -50,6 +51,8 @@ class ShaarliMiddleware
50 51
51 $response = $response->withStatus($e->getCode()); 52 $response = $response->withStatus($e->getCode());
52 $response = $response->write($this->container->pageBuilder->render('error')); 53 $response = $response->write($this->container->pageBuilder->render('error'));
54 } catch (UnauthorizedException $e) {
55 return $response->withRedirect($request->getUri()->getBasePath() . '/login');
53 } 56 }
54 57
55 return $response; 58 return $response;