Skip to content

Commit 9968ef9

Browse files
committed
feature: Added login branding support on tweaks and authentication page
1 parent f08333d commit 9968ef9

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed

app/Http/Controllers/API/AuthController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Classes\Authentication\LDAPAuthenticator;
77
use App\Classes\Authentication\LimanAuthenticator;
88
use App\Http\Controllers\Controller;
9+
use App\Models\SystemSettings;
910
use App\User;
1011
use Illuminate\Auth\Events\PasswordReset;
1112
use Illuminate\Http\JsonResponse;
@@ -34,7 +35,8 @@ public function __construct()
3435
'forceChangePassword',
3536
'setupTwoFactorAuthentication',
3637
'sendPasswordResetLink',
37-
'resetPassword'
38+
'resetPassword',
39+
'loginBranding'
3840
]
3941
]
4042
);
@@ -58,6 +60,16 @@ public function activeAuthTypes()
5860
return $types;
5961
}
6062

63+
/**
64+
* Return login screen branding
65+
*/
66+
public function loginBranding()
67+
{
68+
return response()->json([
69+
'image' => SystemSettings::where('key', 'LOGIN_IMAGE')->first()?->data ?? '',
70+
]);
71+
}
72+
6173
/**
6274
* Get a JWT via given credentials.
6375
*

app/Http/Controllers/API/Settings/CertificateController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function index()
2727
// Certificate is not valid
2828
// Remove certificate from system
2929
$certificate->removeFromSystem();
30-
}
31-
32-
$certificate->valid_to =
33-
$certinfo['validTo_time_t'] * 1000;
30+
} else {
31+
$certificate->valid_to =
32+
$certinfo['validTo_time_t'] * 1000;
3433

35-
$certificate->valid_from =
36-
$certinfo['validFrom_time_t'];
34+
$certificate->valid_from =
35+
$certinfo['validFrom_time_t'];
36+
}
3737
});
3838

3939
return $certificates;

app/Http/Controllers/API/Settings/TweaksController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Models\AuditLog;
7+
use App\Models\SystemSettings;
78
use App\System\Command;
89
use Illuminate\Http\Request;
910

@@ -25,6 +26,7 @@ public function getConfiguration()
2526
'EXTENSION_DEVELOPER_MODE' => (bool) env('EXTENSION_DEVELOPER_MODE', 'false'),
2627
'NEW_LOG_LEVEL' => env('NEW_LOG_LEVEL'),
2728
'LDAP_IGNORE_CERT' => (bool) env('LDAP_IGNORE_CERT', 'false'),
29+
'LOGIN_IMAGE' => SystemSettings::where('key', 'LOGIN_IMAGE')->first()?->data ?? '',
2830
]);
2931
}
3032

@@ -58,6 +60,18 @@ public function saveConfiguration(Request $request)
5860
'LDAP_IGNORE_CERT' => (bool) $request->LDAP_IGNORE_CERT,
5961
]);
6062

63+
if ($request->has('LOGIN_IMAGE') && $request->LOGIN_IMAGE != '')
64+
// Control if LOGIN_IMAGE is bigger than 1mb
65+
if (strlen($request->LOGIN_IMAGE) > 1048576) {
66+
return response()->json([
67+
'LOGIN_IMAGE' => 'Giriş arka planı resmi 1MB\'dan büyük olamaz.',
68+
], 422);
69+
}
70+
SystemSettings::updateOrCreate(
71+
['key' => 'LOGIN_IMAGE'],
72+
['data' => $request->get('LOGIN_IMAGE')]
73+
);
74+
6175
AuditLog::write(
6276
'tweak',
6377
'edit',
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('system_settings', function (Blueprint $table) {
17+
$table->longText('data')->change();
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('system_settings', function (Blueprint $table) {
29+
30+
});
31+
}
32+
};

routes/api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'prefix' => 'auth'
2727
], function () {
2828
Route::get('/types', [AuthController::class, 'activeAuthTypes']);
29+
Route::get('/branding', [AuthController::class, 'loginBranding']);
2930
Route::post('/login', [AuthController::class, 'login'])
3031
->middleware('throttle:login');
3132
Route::post('/setup_mfa', [AuthController::class, 'setupTwoFactorAuthentication']);

0 commit comments

Comments
 (0)