mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Merge branch 'develop' of github.com:invoiceninja/invoiceninja into develop
This commit is contained in:
commit
d5134daa01
@ -16,18 +16,6 @@ class VerifyCsrfToken extends BaseVerifier
|
||||
'complete/*',
|
||||
'signup/register',
|
||||
'api/v1/*',
|
||||
'api/v1/login',
|
||||
'api/v1/clients/*',
|
||||
'api/v1/clients',
|
||||
'api/v1/invoices/*',
|
||||
'api/v1/invoices',
|
||||
'api/v1/quotes',
|
||||
'api/v1/payments',
|
||||
'api/v1/tasks',
|
||||
'api/v1/email_invoice',
|
||||
'api/v1/hooks',
|
||||
'api/v1/users',
|
||||
'api/v1/users/*',
|
||||
'hook/email_opened',
|
||||
'hook/email_bounced',
|
||||
'reseller_stats',
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Libraries\Utils;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Http\Request as InputRequest;
|
||||
use Response;
|
||||
|
||||
|
||||
class CreatePaymentAPIRequest extends PaymentRequest
|
||||
{
|
||||
@ -9,6 +13,12 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public function __construct(InputRequest $req)
|
||||
{
|
||||
$this->req = $req;
|
||||
}
|
||||
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('create', ENTITY_PAYMENT);
|
||||
@ -48,4 +58,24 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
public function response(array $errors)
|
||||
{
|
||||
/* If the user is not validating from a mobile app - pass through parent::response */
|
||||
if(!isset($this->req->api_secret))
|
||||
return parent::response($errors);
|
||||
|
||||
/* If the user is validating from a mobile app - pass through first error string and return error */
|
||||
foreach($errors as $error) {
|
||||
foreach ($error as $key => $value) {
|
||||
|
||||
$message['error'] = ['message'=>$value];
|
||||
$message = json_encode($message, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
return Response::make($message, 400, $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,6 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
||||
Route::get('invoices', 'InvoiceApiController@index');
|
||||
Route::get('download/{invoice_id}', 'InvoiceApiController@download');
|
||||
Route::resource('invoices', 'InvoiceApiController');
|
||||
Route::get('payments', 'PaymentApiController@index');
|
||||
Route::resource('payments', 'PaymentApiController');
|
||||
Route::get('tasks', 'TaskApiController@index');
|
||||
Route::resource('tasks', 'TaskApiController');
|
||||
|
Loading…
Reference in New Issue
Block a user