Fix JWT validation: use user_id instead of sub in socket servers, revert statusDriverLocation from toggleActive

This commit is contained in:
Hamza-Ayed
2026-08-01 17:57:47 +03:00
parent 1ddc6f8aa7
commit 77d7d9faf8
4 changed files with 3 additions and 6 deletions
+1 -1
View File
@@ -731,7 +731,7 @@ $io->on('connection', function ($socket) use ($INTERNAL_KEY) {
} else {
$decoded = JWT::decode($jwtToken, new Key($secretKey, 'HS256'));
// Validate that the token belongs to this driver
if ((string)$decoded->sub !== (string)$driverId || $decoded->role !== 'driver') {
if ((string)$decoded->user_id !== (string)$driverId || $decoded->role !== 'driver') {
logMsg("🚫 Connection Rejected: Invalid JWT for driver_id=$driverId");
$socket->disconnect();
return;