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
|
||||
$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);
|
||||
|
||||
Reference in New Issue
Block a user