aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/ShaarliMiddleware.php
diff options
context:
space:
mode:
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;