Update: 2026-05-04 00:13:56

This commit is contained in:
Hamza-Ayed
2026-05-04 00:13:56 +03:00
parent 8357add763
commit 671db50f16
5 changed files with 42 additions and 2 deletions

View File

@@ -52,6 +52,12 @@ foreach ($companies as &$company) {
unset($company['jofotara_client_id_encrypted']);
unset($company['jofotara_secret_key_encrypted']);
unset($company['certificate_password_encrypted']);
// Decrypt Tenant Name (if exists)
if (isset($company['tenant_name'])) {
$decTenantName = Encryption::decrypt($company['tenant_name']);
$company['tenant_name'] = $decTenantName !== false ? $decTenantName : $company['tenant_name'];
}
}
json_success($companies);

View File

@@ -40,11 +40,14 @@ try {
);
// 1. Create Tenant
$encryptedTenantName = \App\Core\Encryption::encrypt($data['name']);
$encryptedTenantEmail = \App\Core\Encryption::encrypt($data['email']);
$stmt = $db->prepare("INSERT INTO tenants (id, name, email, phone, status, created_at) VALUES (?, ?, ?, ?, 'active', NOW())");
$stmt->execute([
$tenantId,
$data['name'],
$data['email'],
$encryptedTenantName,
$encryptedTenantEmail,
$data['phone'] ?? null
]);

View File

@@ -17,4 +17,12 @@ $db = Database::getInstance();
$stmt = $db->query("SELECT id, name, email, phone, status, created_at FROM tenants ORDER BY created_at DESC");
$tenants = $stmt->fetchAll();
foreach ($tenants as &$t) {
$decName = \App\Core\Encryption::decrypt($t['name']);
$t['name'] = $decName !== false ? $decName : $t['name'];
$decEmail = \App\Core\Encryption::decrypt($t['email']);
$t['email'] = $decEmail !== false ? $decEmail : $t['email'];
}
json_success($tenants);

View File

@@ -54,6 +54,12 @@ foreach ($users as &$user) {
$decryptedCompanyName = Encryption::decrypt($user['company_name']);
$user['company_name'] = $decryptedCompanyName !== false ? $decryptedCompanyName : $user['company_name'];
}
// Decrypt Tenant Name (if exists)
if ($user['tenant_name']) {
$decryptedTenantName = Encryption::decrypt($user['tenant_name']);
$user['tenant_name'] = $decryptedTenantName !== false ? $decryptedTenantName : $user['tenant_name'];
}
}
json_success($users);

17
scripts/debug_data.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
require_once __DIR__ . '/../app/bootstrap/init.php';
use App\Core\Database;
$db = Database::getInstance();
echo "--- TENANTS ---\n";
$stmt = $db->query("SELECT * FROM tenants");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
echo "\n--- USERS ---\n";
$stmt = $db->query("SELECT u.id, u.name, u.role, u.tenant_id, t.name as tenant_name FROM users u LEFT JOIN tenants t ON u.tenant_id = t.id");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
echo "\n--- COMPANIES ---\n";
$stmt = $db->query("SELECT * FROM companies");
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));