Files
portal-api/app/Http/Controllers/Api/Client/ClientController.php
T
baodev0andClaude Sonnet 5 12d5b4951c feat: popup quảng cáo, đặt lại mật khẩu bằng token 80 ký tự, 2FA email, vá lỗ hổng bảo mật
- 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>
2026-10-13 13:23:33 +07:00

103 lines
4.8 KiB
PHP

<?php
namespace App\Http\Controllers\Api\Client;
use App\Http\Controllers\Controller;
use App\Http\Resources\Api\Client\ClientResource;
use App\Services\ActivityLogger;
use App\Services\Api\Client\ClientAuthService;
use App\Http\Controllers\Api\Client\Concerns\HandlesClientAuthentication;
use App\Http\Controllers\Api\Client\Concerns\HandlesClientPasswordReset;
use App\Http\Controllers\Api\Client\Concerns\HandlesClientTwoFactor;
use App\Http\Controllers\Api\Client\Concerns\ManagesClientAccountSettings;
use App\Http\Controllers\Api\Client\Concerns\ManagesClientProfile;
/**
* @OA\Tag(
* name="Client Authentication",
* description="API Endpoints for Client Authentication"
* )
*/
class ClientController extends Controller
{
use HandlesClientAuthentication;
use HandlesClientPasswordReset;
use HandlesClientTwoFactor;
use ManagesClientAccountSettings;
use ManagesClientProfile;
protected $authService;
protected ActivityLogger $activityLogger;
public function __construct(ClientAuthService $authService, ActivityLogger $activityLogger)
{
$this->authService = $authService;
$this->activityLogger = $activityLogger;
}
/**
* @OA\Get(
* path="/client/me",
* operationId="getClientMe",
* tags={"Client Authentication"},
* summary="Get current client information",
* description="Returns the currently authenticated client's details",
* security={{"bearerAuth":{}}},
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(property="customer", type="object",
* @OA\Property(property="fullname", type="string", example="Nguyen Van A"),
* @OA\Property(property="email", type="string", example="client@example.com"),
* @OA\Property(property="phone", type="string", example="0987654321"),
* @OA\Property(property="address", type="string", example="123 Street"),
* @OA\Property(property="city", type="string", example="Hanoi"),
* @OA\Property(property="ward", type="string", example="Ward 1"),
* @OA\Property(property="province", type="string", example="Hanoi"),
* @OA\Property(property="gender", type="string", example="Nam"),
* @OA\Property(property="date", type="string", format="date-time", example="2024-01-01 12:00:00"),
* @OA\Property(property="company", type="string", example="Company Ltd"),
* @OA\Property(property="avatar", type="string", example="/uploads/avatar.jpg"),
* @OA\Property(property="cmnd_after", type="string", example="cmnd_back.jpg"),
* @OA\Property(property="cmnd_before", type="string", example="cmnd_front.jpg"),
* @OA\Property(property="cmnd", type="string", example="123456789"),
* @OA\Property(property="fb_link", type="string", nullable=true),
* @OA\Property(property="active_2fa", type="integer", example=0),
* @OA\Property(property="off_mail_marketing", type="integer", example=0),
* @OA\Property(property="is_recharge_zalo", type="integer", example=0),
* @OA\Property(property="is_verify_telegram", type="integer", example=0)
* ),
* @OA\Property(property="credit", type="object",
* @OA\Property(property="credit", type="number", example=1000000),
* @OA\Property(property="total", type="number", example=5000000),
* @OA\Property(property="point", type="number", example=100),
* @OA\Property(property="point_used", type="integer", example=0),
* @OA\Property(property="point_total", type="number", example=100)
* ),
* @OA\Property(property="service", type="object",
* @OA\Property(property="vps", type="integer", example=2),
* @OA\Property(property="proxy", type="integer", example=0),
* @OA\Property(property="server", type="integer", example=0),
* @OA\Property(property="hosting", type="integer", example=1),
* @OA\Property(property="domain", type="integer", example=3)
* )
* )
* ),
* @OA\Response(
* response=401,
* description="Unauthenticated"
* )
* )
*/
public function me()
{
return response()->json([
'error' => false,
'data' => [
'client' => new ClientResource(auth('client')->user()),
],
]);
}
}