Update: 2026-05-04 01:55:05
This commit is contained in:
@@ -26,14 +26,12 @@ if (!$companyId || !isset($_FILES['invoice'])) {
|
||||
$tenantId = $decoded['tenant_id'];
|
||||
$userId = $decoded['user_id'];
|
||||
|
||||
// Everyone (except Super Admin who shouldn't upload here) must belong to the tenant
|
||||
// And if they are NOT an admin, they must be assigned to this company
|
||||
if ($decoded['role'] !== 'admin' && $decoded['role'] !== 'super_admin') {
|
||||
$stmt = $db->prepare("SELECT id FROM user_company_assignments WHERE user_id = ? AND company_id = ? AND is_active = 1");
|
||||
$stmt->execute([$userId, $companyId]);
|
||||
if (!$stmt->fetch()) {
|
||||
json_error('Access denied to this company', 403);
|
||||
}
|
||||
// Everyone (except Super Admin) must belong to the same tenant as the company
|
||||
$stmt = $db->prepare("SELECT id FROM companies WHERE id = ? AND tenant_id = ? AND deleted_at IS NULL");
|
||||
$stmt->execute([$companyId, $tenantId]);
|
||||
|
||||
if (!$stmt->fetch()) {
|
||||
json_error('Access denied to this company or invalid company ID', 403);
|
||||
}
|
||||
|
||||
// 4. Handle File Upload
|
||||
|
||||
Reference in New Issue
Block a user