Fix driver token table and IV padding
This commit is contained in:
@@ -28,7 +28,10 @@ class LegacyEncryption
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->key = trim(file_get_contents($keyPath));
|
$this->key = trim(file_get_contents($keyPath));
|
||||||
$this->iv = config('intaleq.legacy_iv', '');
|
$this->iv = config('intaleq.legacy_iv', env('initializationVector', ''));
|
||||||
|
if (strlen($this->iv) !== 16) {
|
||||||
|
$this->iv = str_pad($this->iv, 16, "\0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Security Check: Verify fingerprint matches stored token
|
// Security Check: Verify fingerprint matches stored token
|
||||||
$storedToken = DB::connection('primary')->table('captainToken')
|
$storedToken = DB::connection('primary')->table('driverToken')
|
||||||
->where('captain_id', $driver->id)
|
->where('captain_id', $driver->id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@@ -571,14 +571,14 @@ class AuthController extends Controller
|
|||||||
return $this->failure('Security mismatch: Invalid device fingerprint', 403);
|
return $this->failure('Security mismatch: Invalid device fingerprint', 403);
|
||||||
}
|
}
|
||||||
// Update fingerprint and token
|
// Update fingerprint and token
|
||||||
DB::connection('primary')->table('captainToken')->where('captain_id', $driver->id)
|
DB::connection('primary')->table('driverToken')->where('captain_id', $driver->id)
|
||||||
->update([
|
->update([
|
||||||
'fingerPrint' => $request->input('fingerPrint'),
|
'fingerPrint' => $request->input('fingerPrint'),
|
||||||
'token' => $request->input('fcm_token'),
|
'token' => $request->input('fcm_token'),
|
||||||
'updated_at' => now()
|
'updated_at' => now()
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
DB::connection('primary')->table('captainToken')->insert([
|
DB::connection('primary')->table('driverToken')->insert([
|
||||||
'captain_id' => $driver->id,
|
'captain_id' => $driver->id,
|
||||||
'fingerPrint' => $request->input('fingerPrint'),
|
'fingerPrint' => $request->input('fingerPrint'),
|
||||||
'token' => $request->input('fcm_token'),
|
'token' => $request->input('fcm_token'),
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class LegacyEncryption
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->iv = config('intaleq.legacy_iv', env('initializationVector', ''));
|
$this->iv = config('intaleq.legacy_iv', env('initializationVector', ''));
|
||||||
|
if (strlen($this->iv) !== 16) {
|
||||||
|
$this->iv = str_pad($this->iv, 16, "\0");
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($this->key) !== 32) {
|
if (strlen($this->key) !== 32) {
|
||||||
// Log warning or throw error in production
|
// Log warning or throw error in production
|
||||||
|
|||||||
Reference in New Issue
Block a user