mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-01 18:53:16 +00:00
4248abde7c
Previously the various config checks for curated registration were preventing `artisan route:list` from running successfully. Here we extract that logic from the controller's contructor and place in a middleware around the CuratedRegisterController routes.
28 lines
825 B
PHP
28 lines
825 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class EnsureCuratedRegistration
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
abort_unless((bool) config_cache('instance.curated_registration.enabled'), 404);
|
|
|
|
if ((bool) config_cache('pixelfed.open_registration')) {
|
|
abort_if(config('instance.curated_registration.state.only_enabled_on_closed_reg'), 404);
|
|
} else {
|
|
abort_unless(config('instance.curated_registration.state.fallback_on_closed_reg'), 404);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|