Update: 2026-05-04 00:29:31
This commit is contained in:
@@ -19,19 +19,17 @@ try {
|
|||||||
if ($role === 'super_admin') {
|
if ($role === 'super_admin') {
|
||||||
// Super Admin sees ALL users from ALL tenants
|
// Super Admin sees ALL users from ALL tenants
|
||||||
$stmt = $db->query("
|
$stmt = $db->query("
|
||||||
SELECT u.id, u.name, u.email, u.role, u.is_active, u.created_at, t.name as tenant_name, c.name as company_name
|
SELECT u.id, u.name, u.email, u.role, u.is_active, u.created_at, t.name as tenant_name
|
||||||
FROM users u
|
FROM users u
|
||||||
LEFT JOIN tenants t ON u.tenant_id = t.id
|
LEFT JOIN tenants t ON u.tenant_id = t.id
|
||||||
LEFT JOIN companies c ON u.company_id = c.id
|
|
||||||
ORDER BY u.created_at DESC
|
ORDER BY u.created_at DESC
|
||||||
");
|
");
|
||||||
} elseif ($role === 'admin') {
|
} elseif ($role === 'admin') {
|
||||||
// Admin sees only users in THEIR tenant (Accounting Office)
|
// Admin sees only users in THEIR tenant (Accounting Office)
|
||||||
$stmt = $db->prepare("
|
$stmt = $db->prepare("
|
||||||
SELECT u.id, u.name, u.email, u.role, u.is_active, u.created_at, t.name as tenant_name, c.name as company_name
|
SELECT u.id, u.name, u.email, u.role, u.is_active, u.created_at, t.name as tenant_name
|
||||||
FROM users u
|
FROM users u
|
||||||
LEFT JOIN tenants t ON u.tenant_id = t.id
|
LEFT JOIN tenants t ON u.tenant_id = t.id
|
||||||
LEFT JOIN companies c ON u.company_id = c.id
|
|
||||||
WHERE u.tenant_id = ?
|
WHERE u.tenant_id = ?
|
||||||
ORDER BY u.created_at DESC
|
ORDER BY u.created_at DESC
|
||||||
");
|
");
|
||||||
@@ -52,12 +50,6 @@ try {
|
|||||||
$decryptedEmail = Encryption::decrypt($user['email']);
|
$decryptedEmail = Encryption::decrypt($user['email']);
|
||||||
$user['email'] = $decryptedEmail !== false ? $decryptedEmail : $user['email'];
|
$user['email'] = $decryptedEmail !== false ? $decryptedEmail : $user['email'];
|
||||||
|
|
||||||
// Decrypt Company Name (if exists)
|
|
||||||
if (!empty($user['company_name'])) {
|
|
||||||
$decryptedCompanyName = Encryption::decrypt($user['company_name']);
|
|
||||||
$user['company_name'] = $decryptedCompanyName !== false ? $decryptedCompanyName : $user['company_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decrypt Tenant Name (if exists)
|
// Decrypt Tenant Name (if exists)
|
||||||
if (!empty($user['tenant_name'])) {
|
if (!empty($user['tenant_name'])) {
|
||||||
$decryptedTenantName = Encryption::decrypt($user['tenant_name']);
|
$decryptedTenantName = Encryption::decrypt($user['tenant_name']);
|
||||||
|
|||||||
Reference in New Issue
Block a user