Fix JWT validation: use user_id instead of sub in socket servers, revert statusDriverLocation from toggleActive
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user