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:
@@ -31,6 +31,7 @@ public function mount(): void
|
||||
$siteDescription = Setting::get('site_description');
|
||||
$contactEmail = Setting::get('contact_email');
|
||||
$maintenanceMode = Setting::get('maintenance_mode', false);
|
||||
$enableRegistration = Setting::get('enable_registration', false);
|
||||
|
||||
$this->form->fill([
|
||||
'site_name' => is_string($siteName) ? $siteName : config('app.name'),
|
||||
@@ -41,6 +42,7 @@ public function mount(): void
|
||||
'site_description' => is_string($siteDescription) || is_null($siteDescription) ? $siteDescription : '',
|
||||
'contact_email' => is_string($contactEmail) || is_null($contactEmail) ? $contactEmail : '',
|
||||
'maintenance_mode' => is_bool($maintenanceMode) ? $maintenanceMode : false,
|
||||
'enable_registration' => is_bool($enableRegistration) ? $enableRegistration : false,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -87,6 +89,10 @@ public function form(Form $form): Form
|
||||
|
||||
Forms\Components\Section::make('System')
|
||||
->schema([
|
||||
Forms\Components\Toggle::make('enable_registration')
|
||||
->label('Enable User Registration')
|
||||
->helperText('Allow new users to register. When disabled, only admins can create users.'),
|
||||
|
||||
Forms\Components\Toggle::make('maintenance_mode')
|
||||
->label('Maintenance Mode')
|
||||
->helperText('Enable to put the site in maintenance mode'),
|
||||
@@ -116,6 +122,7 @@ public function save(): void
|
||||
Setting::set('site_description', $data['site_description'] ?? '');
|
||||
Setting::set('contact_email', $data['contact_email'] ?? '');
|
||||
Setting::set('maintenance_mode', $data['maintenance_mode'] ?? false, 'boolean');
|
||||
Setting::set('enable_registration', $data['enable_registration'] ?? false, 'boolean');
|
||||
|
||||
Notification::make()
|
||||
->title('Settings saved successfully')
|
||||
|
||||
Reference in New Issue
Block a user