diff options
Diffstat (limited to 'application/front/ShaarliMiddleware.php')
-rw-r--r-- | application/front/ShaarliMiddleware.php | 7 |
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 @@ | |||
3 | namespace Shaarli\Front; | 3 | namespace Shaarli\Front; |
4 | 4 | ||
5 | use Shaarli\Container\ShaarliContainer; | 5 | use Shaarli\Container\ShaarliContainer; |
6 | use Shaarli\Front\Exception\ShaarliException; | 6 | use Shaarli\Front\Exception\ShaarliFrontException; |
7 | use Shaarli\Front\Exception\UnauthorizedException; | ||
7 | use Slim\Http\Request; | 8 | use Slim\Http\Request; |
8 | use Slim\Http\Response; | 9 | use 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; |