laravel - Laravel - 使用谷歌recaptcha时无法输入错误
问题描述
我在我的登录表单中使用 google recaptcha。我在登录模板中粘贴了脚本标签和代码片段,还添加'g-recaptcha-response' => 'required|captcha',
到validateLogin
了AuthenticatesUsers.php
. 当我提交表格时,我只收到recaptcha 错误,而不是电子邮件或密码输入!当我删除时,'g-recaptcha-response' => 'required|captcha',
我会收到错误!
解决方案
也许您可以尝试自己设置一个新的验证器(不确定它是否可行,这是一个想法)。
这是此文档部分的链接:https ://laravel.com/docs/5.6/validation#manually-creating-validators
以及附加到操作的控制器文件中的示例:
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'g-recaptcha-response' => 'required|captcha',
]);
}
推荐阅读
- javascript - 如何计算当前日期与创建日期的剩余时间?
- php - 在PHP中将空字符串分解为数组
- c# - 过滤 ReportViewer 数据?
- visual-studio-code - 无法从扩展中使用 VSCode CLI
- c++ - 如何创建对象数组并访问子类中的函数?C++
- c# - 关闭应用程序后如何使背景颜色保持不变?
- wordpress - EC2 上的 WordPress 崩溃并无法访问
- reactjs - 无法在开玩笑的测试用例中读取属性 clientHeight 文档
- php - 从数组值填充 HTML 表
- google-sheets - Importhtml 重命名标题名称 Google 表格