mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add duplicate request checks on bulk invoice actions
This commit is contained in:
parent
812bc91947
commit
2221353622
@ -475,7 +475,10 @@ class InvoiceController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(DestroyInvoiceRequest $request, Invoice $invoice)
|
public function destroy(DestroyInvoiceRequest $request, Invoice $invoice)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!$invoice->is_deleted) {
|
||||||
$this->invoice_repo->delete($invoice);
|
$this->invoice_repo->delete($invoice);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->itemResponse($invoice->fresh());
|
return $this->itemResponse($invoice->fresh());
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,23 @@ class DestroyInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
return auth()->user()->can('edit', $this->invoice);
|
return auth()->user()->can('edit', $this->invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->invoice->id."|".$user->company()->company_key))
|
||||||
|
throw new \App\Exceptions\DuplicatePaymentException('Duplicate request.', 429);
|
||||||
|
|
||||||
|
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->invoice->id."|".$user->company()->company_key), true, 1);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
public/build/assets/app-23f93261.css
vendored
Normal file
1
public/build/assets/app-23f93261.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user