Update: 2026-05-04 16:06:15
This commit is contained in:
@@ -32,7 +32,7 @@ if (preg_match('/Bearer\s(\S+)/', $authHeader, $matches)) {
|
||||
|
||||
if (!$token) outputErrorImage('Forbidden: No token');
|
||||
|
||||
$decoded = \App\Core\JWT::decode($token);
|
||||
$decoded = \App\Core\JWT::decode($token, env('JWT_SECRET', ''));
|
||||
if (!$decoded) outputErrorImage('Forbidden: Invalid token');
|
||||
|
||||
$db = Database::getInstance();
|
||||
|
||||
@@ -59,17 +59,18 @@ try {
|
||||
|
||||
$invoices = $stmt->fetchAll();
|
||||
|
||||
// 3. Decrypt sensitive fields for display
|
||||
// 3. Decrypt sensitive fields for display (Robustly)
|
||||
$decrypt = fn($val) => Encryption::decrypt($val ?? '') ?: ($val ?? '-');
|
||||
foreach ($invoices as &$inv) {
|
||||
$inv['supplier_name'] = Encryption::decrypt($inv['supplier_name'] ?? '') ?: ($inv['supplier_name'] ?? '-');
|
||||
$inv['supplier_tin'] = Encryption::decrypt($inv['supplier_tin'] ?? '') ?: ($inv['supplier_tin'] ?? '-');
|
||||
$inv['buyer_name'] = Encryption::decrypt($inv['buyer_name'] ?? '') ?: ($inv['buyer_name'] ?? '-');
|
||||
$inv['supplier_name'] = $decrypt($inv['supplier_name']);
|
||||
$inv['supplier_tin'] = $decrypt($inv['supplier_tin']);
|
||||
$inv['buyer_name'] = $decrypt($inv['buyer_name']);
|
||||
|
||||
if (!empty($inv['company_name'])) {
|
||||
$inv['company_name'] = Encryption::decrypt($inv['company_name']) ?: $inv['company_name'];
|
||||
$inv['company_name'] = $decrypt($inv['company_name']);
|
||||
}
|
||||
if (!empty($inv['tenant_name'])) {
|
||||
$inv['tenant_name'] = Encryption::decrypt($inv['tenant_name']) ?: $inv['tenant_name'];
|
||||
$inv['tenant_name'] = $decrypt($inv['tenant_name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,16 +43,18 @@ try {
|
||||
$stmtLines->execute([$id]);
|
||||
$invoice['items'] = $stmtLines->fetchAll();
|
||||
|
||||
// 5. Decrypt Fields
|
||||
$invoice['supplier_tin'] = Encryption::decrypt($invoice['supplier_tin'] ?? '') ?: $invoice['supplier_tin'];
|
||||
$invoice['supplier_name'] = Encryption::decrypt($invoice['supplier_name'] ?? '') ?: $invoice['supplier_name'];
|
||||
$invoice['supplier_address'] = Encryption::decrypt($invoice['supplier_address'] ?? '') ?: $invoice['supplier_address'];
|
||||
$invoice['buyer_tin'] = Encryption::decrypt($invoice['buyer_tin'] ?? '') ?: $invoice['buyer_tin'];
|
||||
$invoice['buyer_name'] = Encryption::decrypt($invoice['buyer_name'] ?? '') ?: $invoice['buyer_name'];
|
||||
$invoice['buyer_national_id'] = Encryption::decrypt($invoice['buyer_national_id'] ?? '') ?: $invoice['buyer_national_id'];
|
||||
// 5. Decrypt Fields (Robustly)
|
||||
$decrypt = fn($val) => Encryption::decrypt($val ?? '') ?: $val;
|
||||
|
||||
$invoice['supplier_tin'] = $decrypt($invoice['supplier_tin']);
|
||||
$invoice['supplier_name'] = $decrypt($invoice['supplier_name']);
|
||||
$invoice['supplier_address'] = $decrypt($invoice['supplier_address']);
|
||||
$invoice['buyer_tin'] = $decrypt($invoice['buyer_tin']);
|
||||
$invoice['buyer_name'] = $decrypt($invoice['buyer_name']);
|
||||
$invoice['buyer_national_id'] = $decrypt($invoice['buyer_national_id']);
|
||||
|
||||
if (!empty($invoice['company_name'])) {
|
||||
$invoice['company_name'] = Encryption::decrypt($invoice['company_name']) ?: $invoice['company_name'];
|
||||
$invoice['company_name'] = $decrypt($invoice['company_name']);
|
||||
}
|
||||
|
||||
// 6. Generate Public URL for File (Assuming storage is symlinked or served)
|
||||
|
||||
Reference in New Issue
Block a user