- Popup/banner quảng cáo cấu hình từ admin (loại, link, lịch hiển thị) - Đặt lại mật khẩu: token 80 ký tự kèm check digit Luhn thay cho token+email lộ trong URL, chỉ lưu bản băm, một lần dùng, hết hạn 60 phút - Xác thực 2 lớp qua email khi đăng nhập (mã 6 số, ghi nhớ thiết bị 90 ngày) - ApiAuthCheck chặn ngay tài khoản bị khoá dù JWT còn hạn (trước đây dùng được tới hết TTL) - Handler trả 404 thay vì 500 khi ModelNotFoundException không bọc HttpException - Test ClientTamperingTest: xác nhận IDOR/giả mạo dữ liệu từ client đều bị chặn Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
90 lines
2.5 KiB
PHP
90 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Setting;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\PopupBanner;
|
|
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(),
|
|
]);
|
|
}
|
|
|
|
public function getPopups(): \Illuminate\Http\JsonResponse
|
|
{
|
|
return response()->json(['error' => false, 'data' => PopupBanner::publicList()]);
|
|
}
|
|
}
|