且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel5 CSRF筛选器:返回HTTP 422错误

更新时间:2021-08-08 05:02:21

422 是laravel中通过Ajax提交表单时用于无效数据的自然响应代码.并且您的数据必须包含所有已定义的字段在您的请求规则方法中. 403 表示您无权执行该请求.在您的请求类中,有一个名为authorize()的方法.您可以使用此方法检查用户是否有权发出此请求.返回false,则将出现 403 错误.

422 is natural response code in laravel for invalid data when submitting forms via ajax.And your data must include all fields that is defined in your request rules method. 403 means you are not authorized to perform that request.In your request class there is method called authorize().And you can use this method to check if user has an authority to make this request.If this return false then you will get 403 error.