Handler.php第133行中的HttpException:此操作是未授权的 [英] HttpException in Handler.php line 133: This action is unauthorized

查看:90
本文介绍了Handler.php第133行中的HttpException:此操作是未授权的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用laravel 5.3创建了一个应用程序,并且在localhost上运行良好,但是在服务器上将所有代码升华后,我遇到了以下错误:

I have created an application using laravel 5.3 and it is working fine on localhost but after I uploded all my code on a server I have this error:

Symfony\Component\HttpKernel\Exception\HttpException in /home/project/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php line 133: This action is unauthorized.

当我尝试使用post调用控制器中的函数时,就会发生这种情况.

This is happening when I try to call functions whithin my controllers using post.

这是一个例子:

路线

Route::group(['middleware' => 'auth'], function () {
    Route::group(['middleware' => 'admin'], function () {
         Route::post('admin/store/', 'Admin\AnnouncementController@store');
    });
});

控制器

protected function store(AnnouncementRequest $request) {
    return Auth::user()->id;
}

我该如何解决?为什么在我的本地主机上没有发生这种情况?

How can I fix this? Why is this not happening on my localhost?

提前谢谢.

推荐答案

检查您的AnnouncementRequest文件是否设置为从授权函数返回true.默认值为返回false.

Check that your AnnouncementRequest file is set to return true from authorize function. The default is to return false.

这篇关于Handler.php第133行中的HttpException:此操作是未授权的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆