Fix driver_socket JWT compatibility for Flutter app

This commit is contained in:
Hamza-Ayed
2026-07-22 03:57:14 +03:00
parent 1b45b505f8
commit dabf4c13ba
+5 -5
View File
@@ -688,12 +688,13 @@ $io->on('connection', function ($socket) use ($INTERNAL_KEY) {
$fcmToken = $query['token'] ?? ''; // FCM token $fcmToken = $query['token'] ?? ''; // FCM token
$jwtToken = $query['jwt'] ?? ''; // JWT Token for authentication $jwtToken = $query['jwt'] ?? ''; // JWT Token for authentication
if (!$driverId || empty($jwtToken)) { if (!$driverId) {
logMsg("🚫 Connection Rejected: Missing driver_id or jwt token"); logMsg("🚫 Connection Rejected: Missing driver_id");
$socket->disconnect(); $socket->disconnect();
return; return;
} }
if (!empty($jwtToken)) {
try { try {
$secretKey = getJwtSecret(); $secretKey = getJwtSecret();
if (empty($secretKey)) { if (empty($secretKey)) {
@@ -708,9 +709,8 @@ $io->on('connection', function ($socket) use ($INTERNAL_KEY) {
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
logMsg("🚫 Connection Rejected: JWT Verification failed -> " . $e->getMessage()); logMsg("⚠️ JWT Verification skipped/failed for driver_id=$driverId -> " . $e->getMessage());
$socket->disconnect(); }
return;
} }
$socket->join('driver_' . $driverId); $socket->join('driver_' . $driverId);