X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Ffront%2FShaarliMiddleware.php;h=d1aa139989e2689ee61df29f47c2cd08bd2d9999;hb=a4a59e183e565a6933925b3cb30fc8393639ac5a;hp=a2a3837b9e2bd1560899af8e249f5dc9338d4c52;hpb=bedbb845eec20363b928b424143787dbe988eefe;p=github%2Fshaarli%2FShaarli.git diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php index a2a3837b..d1aa1399 100644 --- a/application/front/ShaarliMiddleware.php +++ b/application/front/ShaarliMiddleware.php @@ -3,7 +3,6 @@ namespace Shaarli\Front; use Shaarli\Container\ShaarliContainer; -use Shaarli\Front\Exception\ShaarliFrontException; use Shaarli\Front\Exception\UnauthorizedException; use Slim\Http\Request; use Slim\Http\Response; @@ -53,35 +52,12 @@ class ShaarliMiddleware $this->checkOpenShaarli($request, $response, $next); return $next($request, $response); - } catch (ShaarliFrontException $e) { - // Possible functional error - $this->container->pageBuilder->reset(); - $this->container->pageBuilder->assign('message', nl2br($e->getMessage())); - - $response = $response->withStatus($e->getCode()); - - return $response->write($this->container->pageBuilder->render('error', $this->container->basePath)); } catch (UnauthorizedException $e) { $returnUrl = urlencode($this->container->environment['REQUEST_URI']); return $response->withRedirect($this->container->basePath . '/login?returnurl=' . $returnUrl); - } catch (\Throwable $e) { - // Unknown error encountered - $this->container->pageBuilder->reset(); - if ($this->container->conf->get('dev.debug', false)) { - $this->container->pageBuilder->assign('message', $e->getMessage()); - $this->container->pageBuilder->assign( - 'stacktrace', - nl2br(get_class($e) .': '. PHP_EOL . $e->getTraceAsString()) - ); - } else { - $this->container->pageBuilder->assign('message', t('An unexpected error occurred.')); - } - - $response = $response->withStatus(500); - - return $response->write($this->container->pageBuilder->render('error', $this->container->basePath)); } + // Other exceptions are handled by ErrorController } /** @@ -118,7 +94,7 @@ class ShaarliMiddleware && $this->container->conf->get('privacy.force_login') // and the current page isn't already the login page // and the user is not requesting a feed (which would lead to a different content-type as expected) - && !in_array($next->getName(), ['login', 'atom', 'rss'], true) + && !in_array($next->getName(), ['login', 'processLogin', 'atom', 'rss'], true) ) { throw new UnauthorizedException(); }