mirror of
https://github.com/flarum/core.git
synced 2025-08-23 08:33:45 +02:00
Cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import Page from '../../common/components/Page';
|
import Page from '../../common/components/Page';
|
||||||
|
|
||||||
export default class NotAuthenticatedErrorPage extends Page {
|
export default class ErrorPage extends Page {
|
||||||
view() {
|
view() {
|
||||||
return (
|
return (
|
||||||
<div className="ErrorPage">
|
<div className="ErrorPage">
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
namespace Flarum\Foundation\ErrorHandling;
|
namespace Flarum\Foundation\ErrorHandling;
|
||||||
|
|
||||||
use Flarum\Frontend\Controller;
|
use Flarum\Frontend\Controller;
|
||||||
|
use Flarum\Frontend\Frontend;
|
||||||
use Flarum\Http\Content\NotAuthenticated;
|
use Flarum\Http\Content\NotAuthenticated;
|
||||||
use Flarum\Http\Content\NotFound;
|
use Flarum\Http\Content\NotFound;
|
||||||
use Flarum\Http\Content\PermissionDenied;
|
use Flarum\Http\Content\PermissionDenied;
|
||||||
@@ -20,38 +21,18 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
|||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A formatter for turning caught exceptions into "pretty" HTML error pages.
|
* This formatter will route certain errors to the SPA frontend.
|
||||||
*
|
|
||||||
* For certain known error types, we display pages with dedicated information
|
|
||||||
* relevant to this class of error, e.g. a page with a search form for HTTP 404
|
|
||||||
* "Not Found" errors. We look for templates in the `views/error` directory.
|
|
||||||
*
|
|
||||||
* If no specific template exists, a generic "Something went wrong" page will be
|
|
||||||
* displayed, optionally enriched with a more specific error message if found in
|
|
||||||
* the translation files.
|
|
||||||
*/
|
*/
|
||||||
class FrontendFormatter implements HttpFormatter
|
class FrontendFormatter implements HttpFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Container
|
* @var Frontend
|
||||||
*/
|
*/
|
||||||
protected $container;
|
protected $frontend;
|
||||||
|
|
||||||
/**
|
public function __construct(Frontend $frontend)
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var SettingsRepositoryInterface
|
|
||||||
*/
|
|
||||||
protected $settings;
|
|
||||||
|
|
||||||
public function __construct(Container $container, TranslatorInterface $translator, SettingsRepositoryInterface $settings)
|
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->frontend = $frontend;
|
||||||
$this->translator = $translator;
|
|
||||||
$this->settings = $settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format(HandledError $error, Request $request): Response
|
public function format(HandledError $error, Request $request): Response
|
||||||
|
@@ -17,7 +17,7 @@ class NotAuthenticated
|
|||||||
public function __invoke(Document $document, Request $request)
|
public function __invoke(Document $document, Request $request)
|
||||||
{
|
{
|
||||||
$document->title = 'Not Authenticated';
|
$document->title = 'Not Authenticated';
|
||||||
$document->payload['errorCode'] = 103;
|
$document->payload['errorCode'] = 401;
|
||||||
|
|
||||||
return $document;
|
return $document;
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ use Flarum\Foundation\ErrorHandling\FrontendFormatter;
|
|||||||
use Flarum\Foundation\ErrorHandling\Registry;
|
use Flarum\Foundation\ErrorHandling\Registry;
|
||||||
use Flarum\Foundation\ErrorHandling\Reporter;
|
use Flarum\Foundation\ErrorHandling\Reporter;
|
||||||
use Flarum\Foundation\ErrorHandling\WhoopsFormatter;
|
use Flarum\Foundation\ErrorHandling\WhoopsFormatter;
|
||||||
|
use Flarum\Frontend\Frontend;
|
||||||
use Flarum\Http\Exception\RouteNotFoundException;
|
use Flarum\Http\Exception\RouteNotFoundException;
|
||||||
use Flarum\User\Exception\NotAuthenticatedException;
|
use Flarum\User\Exception\NotAuthenticatedException;
|
||||||
use Flarum\User\Exception\PermissionDeniedException;
|
use Flarum\User\Exception\PermissionDeniedException;
|
||||||
@@ -88,6 +89,12 @@ class HttpServiceProvider extends AbstractServiceProvider
|
|||||||
$this->container->make('flarum.http.frontend_exceptions')
|
$this->container->make('flarum.http.frontend_exceptions')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->container->when(FrontendFormatter::class)
|
||||||
|
->needs(Frontend::class)
|
||||||
|
->give(function () {
|
||||||
|
return $this->container->make('flarum.frontend.forum');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user