@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Support\PublicRegistration;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class EnsurePublicRegistrationEnabled
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if ($request->routeIs('register', 'register.store')) {
|
||||
abort_unless(PublicRegistration::enabled(), 404);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class PublicRegistration
|
||||
{
|
||||
public static function enabled(): bool
|
||||
{
|
||||
$enabled = DB::table('public_registration_settings')->where('id', 1)->value('enabled');
|
||||
|
||||
return (bool) ($enabled ?? config('fortify.public_registration_default'));
|
||||
}
|
||||
|
||||
public static function setEnabled(bool $enabled): void
|
||||
{
|
||||
DB::table('public_registration_settings')->upsert(
|
||||
['id' => 1, 'enabled' => $enabled],
|
||||
['id'],
|
||||
['enabled'],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user