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'];
|
$tenantId = $decoded['tenant_id'];
|
||||||
$userId = $decoded['user_id'];
|
$userId = $decoded['user_id'];
|
||||||
|
|
||||||
// Everyone (except Super Admin who shouldn't upload here) must belong to the tenant
|
// Everyone (except Super Admin) must belong to the same tenant as the company
|
||||||
// And if they are NOT an admin, they must be assigned to this company
|
$stmt = $db->prepare("SELECT id FROM companies WHERE id = ? AND tenant_id = ? AND deleted_at IS NULL");
|
||||||
if ($decoded['role'] !== 'admin' && $decoded['role'] !== 'super_admin') {
|
$stmt->execute([$companyId, $tenantId]);
|
||||||
$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()) {
|
||||||
if (!$stmt->fetch()) {
|
json_error('Access denied to this company or invalid company ID', 403);
|
||||||
json_error('Access denied to this company', 403);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Handle File Upload
|
// 4. Handle File Upload
|
||||||
|
|||||||
Reference in New Issue
Block a user