mirror of
https://github.com/flarum/core.git
synced 2025-08-17 13:54:18 +02:00
Cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Page from '../../common/components/Page';
|
||||
|
||||
export default class NotAuthenticatedErrorPage extends Page {
|
||||
export default class ErrorPage extends Page {
|
||||
view() {
|
||||
return (
|
||||
<div className="ErrorPage">
|
||||
|
@@ -25,7 +25,7 @@ export default function (app) {
|
||||
|
||||
settings: { path: '/settings', component: SettingsPage },
|
||||
notifications: { path: '/notifications', component: NotificationsPage },
|
||||
|
||||
|
||||
error: { path: '/:error', component: ErrorPage },
|
||||
};
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
namespace Flarum\Foundation\ErrorHandling;
|
||||
|
||||
use Flarum\Frontend\Controller;
|
||||
use Flarum\Frontend\Frontend;
|
||||
use Flarum\Http\Content\NotAuthenticated;
|
||||
use Flarum\Http\Content\NotFound;
|
||||
use Flarum\Http\Content\PermissionDenied;
|
||||
@@ -20,38 +21,18 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* A formatter for turning caught exceptions into "pretty" HTML error pages.
|
||||
*
|
||||
* 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.
|
||||
* This formatter will route certain errors to the SPA frontend.
|
||||
*/
|
||||
class FrontendFormatter implements HttpFormatter
|
||||
{
|
||||
/**
|
||||
* @var Container
|
||||
* @var Frontend
|
||||
*/
|
||||
protected $container;
|
||||
protected $frontend;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @var SettingsRepositoryInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
public function __construct(Container $container, TranslatorInterface $translator, SettingsRepositoryInterface $settings)
|
||||
public function __construct(Frontend $frontend)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->translator = $translator;
|
||||
$this->settings = $settings;
|
||||
$this->frontend = $frontend;
|
||||
}
|
||||
|
||||
public function format(HandledError $error, Request $request): Response
|
||||
|
@@ -17,7 +17,7 @@ class NotAuthenticated
|
||||
public function __invoke(Document $document, Request $request)
|
||||
{
|
||||
$document->title = 'Not Authenticated';
|
||||
$document->payload['errorCode'] = 103;
|
||||
$document->payload['errorCode'] = 401;
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ use Flarum\Foundation\ErrorHandling\FrontendFormatter;
|
||||
use Flarum\Foundation\ErrorHandling\Registry;
|
||||
use Flarum\Foundation\ErrorHandling\Reporter;
|
||||
use Flarum\Foundation\ErrorHandling\WhoopsFormatter;
|
||||
use Flarum\Frontend\Frontend;
|
||||
use Flarum\Http\Exception\RouteNotFoundException;
|
||||
use Flarum\User\Exception\NotAuthenticatedException;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
@@ -88,6 +89,12 @@ class HttpServiceProvider extends AbstractServiceProvider
|
||||
$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