mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Rate limit invoice deletion
This commit is contained in:
parent
5db3eb3d53
commit
6f5daf6f2a
@ -503,7 +503,7 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
$invoices = Invoice::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
|
$invoices = Invoice::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
|
||||||
|
|
||||||
if (! $invoices) {
|
if ($invoices->count() == 0 ) {
|
||||||
return response()->json(['message' => 'No Invoices Found']);
|
return response()->json(['message' => 'No Invoices Found']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Http\Requests\Invoice;
|
namespace App\Http\Requests\Invoice;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Exceptions\DuplicatePaymentException;
|
||||||
|
|
||||||
class BulkInvoiceRequest extends Request
|
class BulkInvoiceRequest extends Request
|
||||||
{
|
{
|
||||||
@ -29,7 +30,21 @@ class BulkInvoiceRequest extends Request
|
|||||||
'template' => 'sometimes|string',
|
'template' => 'sometimes|string',
|
||||||
'template_id' => 'sometimes|string',
|
'template_id' => 'sometimes|string',
|
||||||
'send_email' => 'sometimes|bool',
|
'send_email' => 'sometimes|bool',
|
||||||
'subscriptin_id' => 'sometimes|string',
|
'subscription_id' => 'sometimes|string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$this->input('ids', '')."|".$user->company()->company_key))
|
||||||
|
throw new DuplicatePaymentException('Duplicate request.', 429);
|
||||||
|
|
||||||
|
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$this->input('ids', '')."|".$user->company()->company_key), true, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ class InvoiceRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function delete($invoice): Invoice
|
public function delete($invoice): Invoice
|
||||||
{
|
{
|
||||||
|
$invoice = $invoice->fresh();
|
||||||
|
|
||||||
if ($invoice->is_deleted) {
|
if ($invoice->is_deleted) {
|
||||||
return $invoice;
|
return $invoice;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user