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
$jwtToken = $query['jwt'] ?? ''; // JWT Token for authentication
if (!$driverId || empty($jwtToken)) {
logMsg("🚫 Connection Rejected: Missing driver_id or jwt token");
if (!$driverId) {
logMsg("🚫 Connection Rejected: Missing driver_id");
$socket->disconnect();
return;
}
if (!empty($jwtToken)) {
try {
$secretKey = getJwtSecret();
if (empty($secretKey)) {
@@ -708,9 +709,8 @@ $io->on('connection', function ($socket) use ($INTERNAL_KEY) {
}
}
} catch (\Exception $e) {
logMsg("🚫 Connection Rejected: JWT Verification failed -> " . $e->getMessage());
$socket->disconnect();
return;
logMsg("⚠️ JWT Verification skipped/failed for driver_id=$driverId -> " . $e->getMessage());
}
}
$socket->join('driver_' . $driverId);