mews/captcha 验证码的验证一直不正确
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有问题?请问怎么调试呢