Update: 2026-08-02 17:52:28
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// ============================================================
|
||||
// food/connect_courier.php — بوابة السائق (نوع مهمة «توصيل» داخل تدفّق العروض القائم)
|
||||
// يستخدم JWT الرئيسي نفسه — السائق هو الكابتن نفسه، لا حساب ثانٍ
|
||||
// ============================================================
|
||||
|
||||
require_once __DIR__ . '/../core/bootstrap.php';
|
||||
require_once __DIR__ . '/../functions.php';
|
||||
require_once __DIR__ . '/functions.php';
|
||||
|
||||
if (getenv('FOOD_ENABLED') === 'false') {
|
||||
http_response_code(503);
|
||||
echo json_encode(['status' => 'failure', 'message' => 'Food service is currently disabled']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$limiter = new RateLimiter($redis);
|
||||
$limiter->enforce(RateLimiter::identifier(), 'api');
|
||||
|
||||
$jwtService = new JwtService($redis);
|
||||
$decoded = $jwtService->authenticate();
|
||||
|
||||
if (($decoded->role ?? '') !== 'driver') {
|
||||
jsonError('Forbidden — driver token required', 403);
|
||||
}
|
||||
$food_courier_id = (string)($decoded->user_id ?? '');
|
||||
|
||||
try {
|
||||
$food_con = Database::get('food');
|
||||
} catch (Exception $e) {
|
||||
http_response_code(503);
|
||||
echo json_encode(['status' => 'failure', 'message' => 'Food service unavailable']);
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user