This action is unauthorized.?

Laravel 框架下定义路由后,请求访问数据时,出现:

403
This action is unauthorized.?

使用了自定义的FormRequest,在自定义的 Request 的 authorize 中默认返回了 false

/**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }

修改为 return true; 即可。

Posted in PHP

发表评论

您的电子邮箱地址不会被公开。