mews/captcha 验证码的验证一直不正确

weixin_38069804 2019-09-18 03:51:28
HTML: <input id="captcha" class="form-control" name="captcha" required> <img src="{!! captcha_src() !!}" style="cursor: pointer" onclick="this.src='{{captcha_src()}}'+Math.random()"> $.ajax({ url: "/home/index/login", data: $('form[name="login"]').serialize(), type: "post", dataType: "json", success: function(ret) { } }); PHP: public function login(Request $request) { $this->validate($request, [ 'username' => ['required', 'string', 'max:255'], 'password' => ['required', 'string', 'min:3'], 'captcha' => ['required', 'captcha'] ],[ 'captcha.required' => '验证码不能为空', 'captcha.captcha' => '请输入正确的验证码', ]); $credentials = $request->only('username', 'password'); if (auth('member')->attempt($credentials)) { return $this->success('成功'); } return $this->error('失败'); } 现在是验证码为空时能正确返回 “验证码不能为空” 的报错。 但是输入了验证码一直就是提示 “请输入正确的验证码”。 是不是session有问题?请问怎么调试呢
...全文
477 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38089340 2019-09-18
  • 打赏
  • 举报
回复
是 session 的问题, 你用的 ajax, 哪里有 cookie, 也就不能像后端发送 session id. mews 适应于表单提交形式的验证码, 如果用 ajax, 可以使用 gragwar/captcha

436

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧