first commit

This commit is contained in:
2026-10-09 08:21:06 +02:00
parent db7456df87
commit d259c62304
3761 changed files with 896046 additions and 0 deletions
@@ -0,0 +1,160 @@
<?php
namespace App\Http\Controllers\Web;
use App\Events\Settings\Updated as SettingsUpdated;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response as InertiaResponse;
use Setting;
class SettingsController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Display general settings page.
*/
public function general(): InertiaResponse
{
return Inertia::render('settings/General', [
'values' => ['app_name' => setting('app_name')],
]);
}
/**
* Display Authentication & Registration settings page.
*/
public function auth(): InertiaResponse
{
return Inertia::render('settings/Auth', [
'values' => $this->settingValues([
'remember_me',
'forgot_password',
'login_reset_token_lifetime',
'max_active_sessions',
'throttle_enabled',
'throttle_attempts',
'throttle_lockout_time',
'reg_enabled',
'tos',
'reg_email_confirmation',
'2fa.enabled',
'approval.enabled',
'password-change.enabled',
'registration.captcha.enabled',
]),
'captchaConfigured' => (bool) (config('captcha.secret') && config('captcha.sitekey')),
]);
}
/**
* @param array<int, string> $keys
* @return array<string, mixed>
*/
private function settingValues(array $keys): array
{
$defaults = [
'login_reset_token_lifetime' => 30,
'max_active_sessions' => 0,
'throttle_attempts' => 10,
'throttle_lockout_time' => 1,
];
$values = [];
foreach ($keys as $key) {
$values[$key] = setting($key, $defaults[$key] ?? null);
}
return $values;
}
public function update(Request $request): RedirectResponse
{
$this->updateSetting($request->except('_token'));
return back()->withSuccess(__('Settings updated successfully.'));
}
private function updateSetting(array $input): void
{
foreach ($input as $key => $value) {
Setting::set($key, $value);
}
Setting::save();
event(new SettingsUpdated);
}
public function enableTwoFactor(): RedirectResponse
{
$this->updateSetting(['2fa.enabled' => true]);
return back()->withSuccess(__('Two-Factor Authentication enabled successfully.'));
}
public function disableTwoFactor(): RedirectResponse
{
$this->updateSetting(['2fa.enabled' => false]);
return back()->withSuccess(__('Two-Factor Authentication disabled successfully.'));
}
public function enableApproval(): RedirectResponse
{
$this->updateSetting(['approval.enabled' => true]);
return back()->withSuccess(__('User Confirmation Flow enabled successfully.'));
}
public function disableApproval(): RedirectResponse
{
$this->updateSetting(['approval.enabled' => false]);
return back()->withSuccess(__('User Confirmation Flow disabled successfully.'));
}
public function enablePasswordChange(): RedirectResponse
{
$this->updateSetting(['password-change.enabled' => true]);
return back()->withSuccess(__('Force Password Change for users enabled successfully.'));
}
public function disablePasswordChange(): RedirectResponse
{
$this->updateSetting(['password-change.enabled' => false]);
return back()->withSuccess(__('Force Password Change for users disabled successfully.'));
}
public function enableCaptcha(): RedirectResponse
{
$this->updateSetting(['registration.captcha.enabled' => true]);
return back()->withSuccess(__('reCAPTCHA enabled successfully.'));
}
public function disableCaptcha(): RedirectResponse
{
$this->updateSetting(['registration.captcha.enabled' => false]);
return back()->withSuccess(__('reCAPTCHA disabled successfully.'));
}
public function notifications(): InertiaResponse
{
return Inertia::render('settings/Notifications', [
'values' => [
'notifications_signup_email' => setting('notifications_signup_email'),
],
]);
}
}