- Turnstile (App\Support\Turnstile, middleware turnstile) cho login admin và login/register/forgot/reset của khách; cấu hình ở setting key=turnstile, secret mã hoá SignRSA. - Menu sidebar khách (setting client_menu) và nút tắt topbar (setting client_quick_links) do admin sửa qua administrator/client-menu[/quick-links], khách đọc v1/setting/menu, v1/setting/quick-links. - v1/setting và settings/public chỉ trả whitelist PublicSetting::FIELDS (trước đây lộ bot_token, inet_api_key). - Cài đặt tài khoản khách (preferences), rate limit theo IP cho register/resend-verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.3 KiB
PHP
84 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Setting;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Setting;
|
|
use App\Support\ClientMenu;
|
|
use App\Support\ClientQuickLinks;
|
|
use App\Support\PublicSetting;
|
|
use App\Support\Turnstile;
|
|
|
|
/**
|
|
* @OA\Tag(
|
|
* name="Settings",
|
|
* description="API Endpoints for Application Settings"
|
|
* )
|
|
*/
|
|
class SettingController extends Controller
|
|
{
|
|
/**
|
|
* @OA\Get(
|
|
* path="/setting",
|
|
* operationId="getSetting",
|
|
* tags={"Settings"},
|
|
* summary="Get application settings",
|
|
* description="Returns the public application settings (title, company, logo, favi_icon, brand_color)",
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="Successful operation",
|
|
* @OA\JsonContent(
|
|
* @OA\Property(property="data", type="object"),
|
|
* @OA\Property(property="message", type="string", example="Get setting successfully"),
|
|
* @OA\Property(property="error", type="boolean", example=false)
|
|
* )
|
|
* )
|
|
* )
|
|
*/
|
|
public function getSetting(): \Illuminate\Http\JsonResponse
|
|
{
|
|
return response()->json([
|
|
'data' => PublicSetting::values(),
|
|
'message' => 'Get setting successfully',
|
|
'error' => false
|
|
]);
|
|
}
|
|
|
|
public function getEmailSetting(): \Illuminate\Http\JsonResponse
|
|
{
|
|
$setting = Setting::where('key', 'email_settings')->first();
|
|
$value = $setting ? json_decode($setting->value, true) : [];
|
|
|
|
return response()->json([
|
|
'error' => false,
|
|
'data' => [
|
|
'mail_enabled' => $value['mail_enabled'] ?? true,
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function getTurnstileSetting(): \Illuminate\Http\JsonResponse
|
|
{
|
|
return response()->json([
|
|
'error' => false,
|
|
'data' => ['site_key' => Turnstile::siteKey()],
|
|
]);
|
|
}
|
|
|
|
public function getMenu(): \Illuminate\Http\JsonResponse
|
|
{
|
|
return response()->json([
|
|
'error' => false,
|
|
'data' => ClientMenu::items(),
|
|
]);
|
|
}
|
|
|
|
public function getQuickLinks(): \Illuminate\Http\JsonResponse
|
|
{
|
|
return response()->json([
|
|
'error' => false,
|
|
'data' => ClientQuickLinks::items(),
|
|
]);
|
|
}
|
|
}
|