Redirect landing to login, add registration toggle
Changes: - Landing page (/) now redirects to /login - Added 'Enable User Registration' setting (off by default) - Created CheckRegistrationEnabled middleware - Registration routes blocked when setting is disabled - Admin can toggle registration in Settings > System
This commit is contained in:
26
src/app/Http/Middleware/CheckRegistrationEnabled.php
Normal file
26
src/app/Http/Middleware/CheckRegistrationEnabled.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckRegistrationEnabled
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* Block registration routes if registration is disabled in settings.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$registrationEnabled = Setting::get('enable_registration', false);
|
||||
|
||||
if (!$registrationEnabled) {
|
||||
abort(403, 'User registration is currently disabled. Please contact an administrator.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user