mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
Scope bulk delete to current company to prevent cross-company deletion
Filter customer IDs through whereCompany() before passing to deleteCustomers(), ensuring users cannot delete customers belonging to other companies via the bulk delete endpoint.
This commit is contained in:
@@ -181,3 +181,17 @@ test('cannot update customer from another company', function () {
|
||||
])->assertForbidden();
|
||||
});
|
||||
|
||||
test('cannot bulk delete customer from another company', function () {
|
||||
$otherCompany = Company::factory()->create();
|
||||
$otherCustomer = Customer::factory()->create([
|
||||
'company_id' => $otherCompany->id,
|
||||
]);
|
||||
|
||||
postJson('api/v1/customers/delete', [
|
||||
'ids' => [$otherCustomer->id],
|
||||
])->assertOk();
|
||||
|
||||
$this->assertDatabaseHas('customers', [
|
||||
'id' => $otherCustomer->id,
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user