mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 07:45:22 +00:00
Add hasConfig middleware and use it in GroupController
This commit is contained in:
parent
4248abde7c
commit
a526877dd9
3 changed files with 24 additions and 1 deletions
|
@ -27,7 +27,7 @@ class GroupController extends GroupFederationController
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
abort_unless(config('groups.enabled'), 404);
|
||||
$this->middleware('hasConfig:groups.enabled');
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
|
|
|
@ -71,6 +71,7 @@ class Kernel extends HttpKernel
|
|||
'interstitial' => \App\Http\Middleware\AccountInterstitial::class,
|
||||
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
|
||||
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
|
||||
'hasConfig' => \App\Http\Middleware\HasConfig::class,
|
||||
// 'restricted' => \App\Http\Middleware\RestrictedAccess::class,
|
||||
];
|
||||
}
|
||||
|
|
22
app/Http/Middleware/HasConfig.php
Normal file
22
app/Http/Middleware/HasConfig.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HasConfig
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string $config): Response
|
||||
{
|
||||
abort_unless(config($config), 404);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue