mirror of
https://github.com/flarum/framework.git
synced 2025-02-27 14:13:10 +08:00
Add middleware in admin and forum to some errors via the frontend
This commit is contained in:
parent
f879182ef7
commit
194cf555db
@ -58,6 +58,7 @@ class AdminServiceProvider extends AbstractServiceProvider
|
||||
HttpMiddleware\SetLocale::class,
|
||||
'flarum.admin.route_resolver',
|
||||
HttpMiddleware\CheckCsrfToken::class,
|
||||
'flarum.http.frontend_handler',
|
||||
Middleware\RequireAdministrateAbility::class
|
||||
];
|
||||
});
|
||||
|
@ -69,6 +69,7 @@ class ForumServiceProvider extends AbstractServiceProvider
|
||||
'flarum.forum.route_resolver',
|
||||
HttpMiddleware\CheckCsrfToken::class,
|
||||
HttpMiddleware\ShareErrorsFromSession::class,
|
||||
'flarum.http.frontend_handler',
|
||||
HttpMiddleware\FlarumPromotionHeader::class,
|
||||
];
|
||||
});
|
||||
|
@ -16,6 +16,10 @@ use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\User;
|
||||
use Flarum\User\UsernameSlugDriver;
|
||||
use Illuminate\Support\Arr;
|
||||
use Flarum\Foundation\ErrorHandling\Registry;
|
||||
use Flarum\Foundation\ErrorHandling\Reporter;
|
||||
use Flarum\Foundation\ErrorHandling\FrontendFormatter;
|
||||
use Flarum\Foundation\ErrorHandling\WhoopsFormatter;
|
||||
|
||||
class HttpServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
@ -58,9 +62,28 @@ class HttpServiceProvider extends AbstractServiceProvider
|
||||
|
||||
return $compiledDrivers;
|
||||
});
|
||||
|
||||
$this->container->bind(SlugManager::class, function () {
|
||||
return new SlugManager($this->container->make('flarum.http.selectedSlugDrivers'));
|
||||
});
|
||||
|
||||
$this->container->singleton('flarum.http.frontend_exceptions', function () {
|
||||
return [
|
||||
NotAuthenticatedException::class, // 401
|
||||
PermissionDeniedException::class, // 403
|
||||
ModelNotFoundException::class, // 404
|
||||
RouteNotFoundException::class, // 404
|
||||
];
|
||||
});
|
||||
|
||||
$this->container->singleton('flarum.http.frontend_handler', function () {
|
||||
return new Middleware\HandleErrors(
|
||||
$this->container->make(Registry::class),
|
||||
$this->container['flarum']->inDebugMode() ? $this->container->make(WhoopsFormatter::class) : $this->container->make(FrontendFormatter::class),
|
||||
$this->container->tagged(Reporter::class),
|
||||
$this->container->make('flarum.http.frontend_exceptions')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user