diff --git a/app/Http/Controllers/API/AuthController.php b/app/Http/Controllers/API/AuthController.php index a179ee24..ca768136 100644 --- a/app/Http/Controllers/API/AuthController.php +++ b/app/Http/Controllers/API/AuthController.php @@ -6,6 +6,7 @@ use App\Classes\Authentication\LDAPAuthenticator; use App\Classes\Authentication\LimanAuthenticator; use App\Http\Controllers\Controller; +use App\Models\SystemSettings; use App\User; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Http\JsonResponse; @@ -34,7 +35,8 @@ public function __construct() 'forceChangePassword', 'setupTwoFactorAuthentication', 'sendPasswordResetLink', - 'resetPassword' + 'resetPassword', + 'loginBranding' ] ] ); @@ -58,6 +60,16 @@ public function activeAuthTypes() return $types; } + /** + * Return login screen branding + */ + public function loginBranding() + { + return response()->json([ + 'image' => SystemSettings::where('key', 'LOGIN_IMAGE')->first()?->data ?? '', + ]); + } + /** * Get a JWT via given credentials. * diff --git a/app/Http/Controllers/API/Settings/CertificateController.php b/app/Http/Controllers/API/Settings/CertificateController.php index 27bf4f4b..07ad2a92 100644 --- a/app/Http/Controllers/API/Settings/CertificateController.php +++ b/app/Http/Controllers/API/Settings/CertificateController.php @@ -27,13 +27,13 @@ public function index() // Certificate is not valid // Remove certificate from system $certificate->removeFromSystem(); - } - - $certificate->valid_to = - $certinfo['validTo_time_t'] * 1000; + } else { + $certificate->valid_to = + $certinfo['validTo_time_t'] * 1000; - $certificate->valid_from = - $certinfo['validFrom_time_t']; + $certificate->valid_from = + $certinfo['validFrom_time_t']; + } }); return $certificates; diff --git a/app/Http/Controllers/API/Settings/TweaksController.php b/app/Http/Controllers/API/Settings/TweaksController.php index 904bdf16..c8c8c792 100644 --- a/app/Http/Controllers/API/Settings/TweaksController.php +++ b/app/Http/Controllers/API/Settings/TweaksController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Models\AuditLog; +use App\Models\SystemSettings; use App\System\Command; use Illuminate\Http\Request; @@ -25,6 +26,7 @@ public function getConfiguration() 'EXTENSION_DEVELOPER_MODE' => (bool) env('EXTENSION_DEVELOPER_MODE', 'false'), 'NEW_LOG_LEVEL' => env('NEW_LOG_LEVEL'), 'LDAP_IGNORE_CERT' => (bool) env('LDAP_IGNORE_CERT', 'false'), + 'LOGIN_IMAGE' => SystemSettings::where('key', 'LOGIN_IMAGE')->first()?->data ?? '', ]); } @@ -58,6 +60,18 @@ public function saveConfiguration(Request $request) 'LDAP_IGNORE_CERT' => (bool) $request->LDAP_IGNORE_CERT, ]); + if ($request->has('LOGIN_IMAGE') && $request->LOGIN_IMAGE != '') + // Control if LOGIN_IMAGE is bigger than 1mb + if (strlen($request->LOGIN_IMAGE) > 1048576) { + return response()->json([ + 'LOGIN_IMAGE' => 'Giriş arka planı resmi 1MB\'dan büyük olamaz.', + ], 422); + } + SystemSettings::updateOrCreate( + ['key' => 'LOGIN_IMAGE'], + ['data' => $request->get('LOGIN_IMAGE')] + ); + AuditLog::write( 'tweak', 'edit', diff --git a/database/migrations/2024_05_20_133618_update_value_field_to_long_text_on_system_settings.php b/database/migrations/2024_05_20_133618_update_value_field_to_long_text_on_system_settings.php new file mode 100644 index 00000000..c1004406 --- /dev/null +++ b/database/migrations/2024_05_20_133618_update_value_field_to_long_text_on_system_settings.php @@ -0,0 +1,32 @@ +longText('data')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('system_settings', function (Blueprint $table) { + + }); + } +}; diff --git a/routes/api.php b/routes/api.php index 9c0df814..05fe5e54 100644 --- a/routes/api.php +++ b/routes/api.php @@ -26,6 +26,7 @@ 'prefix' => 'auth' ], function () { Route::get('/types', [AuthController::class, 'activeAuthTypes']); + Route::get('/branding', [AuthController::class, 'loginBranding']); Route::post('/login', [AuthController::class, 'login']) ->middleware('throttle:login'); Route::post('/setup_mfa', [AuthController::class, 'setupTwoFactorAuthentication']);