尝试访问我的控制器时被禁止

时间:2019-03-27 14:16:12

标签: laravel laravel-5

我创建了一个表单,提交后需要转到控制器功能。

在我提交表单的那一刻,我一直在获取

  

禁止

     

您无权访问此服务器上的/ client_area / shop / payment-gateway。

     

此外,尝试使用ErrorDocument处理请求时遇到403禁止错误。

我以前做过表格,但这是我第一次发生这种情况,这让我感到很沮丧。

我的表格

p

我的路线

2

我只做了<div class="payment-form"> <form action="{{ route('payment.gateway') }}" method="POST"> @csrf <input type="hidden" name="return_url" value="{{ route('payment.success') }}"> <input type="hidden" name="cancel_url" value="{{ route('payment.cancel') }}"> <input type="hidden" name="m_payment_id" value="{{ $invoice_number }}"> <input type="hidden" name="amount" class="completePrice" value=""> <input type="hidden" name="item_name" value="Test Item"> <input type="hidden" name="item_description" value="A test product"> <input type="hidden" name="delivery_collection" class="delivery_collection" value=""> <input type="hidden" name="delivery_fee" class="delivery_fee" value="{{ $delivery }}"> <input type="hidden" name="delivery_address" class="delivery_address" value="{{ $address }}"> <button type="submit" class="btn btn-success float-right confirm-order"> Confirm Order </button> </form> </div> 以确保我点击了正确的功能

Route::group(['middleware' => ['web', 'auth']], function(){
    Route::get('/account/dashboard', 'UsersController@accountDashboard')->name('account.dashboard');
    Route::get('/account/details', 'UsersController@personalDetails')->name('account.details');
    Route::get('/account/track-orders', 'UsersController@trackOrders')->name('account.track-orders');
    Route::get('/account/invoices', 'UsersController@invoices')->name('account.invoices');
    Route::get('/account/address', 'UsersController@addressesIndex')->name('account.addresses.index');
    Route::get('/account/sort-orders', 'UsersController@sortOrders')->name('account.sort-orders');
    Route::get('/account/order-details/{invoice_number}', 'UsersController@orderDetails')->name('account.order-details');
    Route::get('/account/invoice-pdf/{id}', 'UsersController@invoicesPdf')->name('account.invoices.pdf');
    Route::get('/account/create-address', 'UsersController@createAddress')->name('account.create.address');
    Route::get('/account/edit-address/{id}', 'UsersController@editAddress')->name('account.edit.address');
    Route::get('/delivery-confirmation', 'PublicController@deliveryConfirmation')->name('cart.deliveryConfirmation');
    Route::get('/account/edit-delivery-address/{id}', 'UsersController@editDeliveryAddress')->name('account.edit.delivery.address');
    Route::get('/payment-success', 'PublicController@successPayment')->name('payment.success');
    Route::get('/payment-cancel', 'PublicController@cancelPayment')->name('payment.cancel');

    Route::post('/account/personal-details', 'UsersController@postPersonalDetails')->name('post.personal-details');
    Route::post('/account/business-details', 'UsersController@postBusinessDetails')->name('post.business-details');
    Route::post('/account/addresses-radio/{id}', 'UsersController@postAddressesRadio')->name('account.post.addresses.radio');
    Route::post('/account/create-address', 'UsersController@postAddress')->name('account.post.address');
    Route::post('/account/edit-address/{id}', 'UsersController@updateAddress')->name('account.update.address');
    Route::post('/payment-gateway', 'PublicController@paymentGateway')->name('payment.gateway');

    Route::delete('/account/delete-delivery-address/{id}', 'UsersController@deleteDeliveryAddress')->name('account.delete.delivery.address');
});

我的身份验证中间件

dd()

这是我在网络标签中看到的内容。因为它包含大量图像,所以我认为将其作为链接而不是仅将图像粘贴到此处会更好。

Image 1

Image 2

Image 3

Image 4

Image 5

Image 6

Image 7

Image 8

1 个答案:

答案 0 :(得分:0)

Laravel具有跨站点请求伪造保护。您还需要传递一个名为csrf-token的字段,如文档中所述。 https://laravel.com/docs/5.8/csrf#csrf-x-csrf-token

如果您不希望获得此保护,则必须将路由包含在VerifyCsrfToken中间件中以排除检查。 https://laravel.com/docs/5.8/csrf#csrf-excluding-uris

尝试此操作是否可以解决您的问题。