enable us to disable registration
tests / ci (push) Waiting to run

This commit is contained in:
Mark Gregory
2026-11-16 10:12:10 +00:00
parent ff2ef836c6
commit 523d4f087f
11 changed files with 150 additions and 6 deletions
@@ -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);
}
}
+24
View File
@@ -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'],
);
}
}