gpt4 book ai didi

php - Laravel 5 mewebstudio/验证码不工作

转载 作者:可可西里 更新时间:2023-11-01 00:41:38 27 4
gpt4 key购买 nike

我在使用 Laravel 5 mewebstudio/captcha 时遇到了问题。

我安装它并且在我的页面上是验证码图像

echo captcha_img()
echo Form::text('captcha','',["class"=>"form-control","placeholder"=>trans('page.captcha')]);

这很好用。

但问题在于验证,在验证表单之后我收到一条关于错误验证码的消息。

我的验证码:

    if (Request::isMethod('post')){

//$data = Input::except(array('_token'));
$data = Input::all();
$rule = array(
'name' => 'required',
'firstname' => 'required',
'bdate' => 'required',
'email' => 'required|email',
'password' => 'required|min:6|same:password_repeat',
'password_repeat' => 'required|min:6',
'captcha' => 'required|captcha'

);

$validator = Validator::make($data, $rule);

if ($validator->fails()) {

$errors = $validator->messages();

}
}

我认为验证码 session 不起作用,因为在转储 session 后我没有应该放在 session 中的验证码 key (我在 Captcha.php 中找到)

      $this->session->put('captcha', [
'sensitive' => $this->sensitive,
'key' => $this->hasher->make($this->sensitive ? $bag : $this->str->lower($bag))
]);

最佳答案

在 Laravel 5.2 中,您需要将 CaptchaServiceProvider 中的第 29 行更改为

$this->app['router']->group(['middleware' => 'web'], function () {
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha');
});

关于php - Laravel 5 mewebstudio/验证码不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34766412/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com