Fix driver_socket JWT compatibility for Flutter app
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user