Fix JWT validation: use user_id instead of sub in socket servers, revert statusDriverLocation from toggleActive
This commit is contained in:
@@ -387,7 +387,6 @@ class HomeCaptainController extends GetxController {
|
||||
_checkFatigueBeforeOnline(); // Throws exception if tired
|
||||
|
||||
if (double.parse(totalPoints) > minPointsThreshold) {
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
locationController.startLocationUpdates();
|
||||
HapticFeedback.heavyImpact();
|
||||
activeStartTime = DateTime.now();
|
||||
@@ -412,7 +411,6 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
locationController.stopLocationUpdates();
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
@@ -427,7 +425,6 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
locationController.stopLocationUpdates();
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -209,7 +209,7 @@ $io->on('connection', function ($socket) {
|
||||
socket_log("[WARNING] JWT Secret is not configured on the server!");
|
||||
} else {
|
||||
$decoded = JWT::decode($jwtToken, new Key($secretKey, 'HS256'));
|
||||
if ((string)$decoded->sub !== (string)$passengerId || $decoded->role !== 'passenger') {
|
||||
if ((string)$decoded->user_id !== (string)$passengerId || $decoded->role !== 'passenger') {
|
||||
socket_log("[SOCKET_REJECTED] Connection rejected: Invalid JWT for passenger_id=$passengerId from IP: $clientIp");
|
||||
$socket->disconnect();
|
||||
return;
|
||||
|
||||
@@ -221,7 +221,7 @@ $io->on('connection', function ($socket) {
|
||||
socket_log("[WARNING] JWT Secret is not configured on the server!");
|
||||
} else {
|
||||
$decoded = JWT::decode($jwtToken, new Key($secretKey, 'HS256'));
|
||||
if ((string)$decoded->sub !== (string)$passengerId || $decoded->role !== 'passenger') {
|
||||
if ((string)$decoded->user_id !== (string)$passengerId || $decoded->role !== 'passenger') {
|
||||
socket_log("[SOCKET_REJECTED] Connection rejected: Invalid JWT for passenger_id=$passengerId from IP: $clientIp");
|
||||
$socket->disconnect();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user