2016-01-13 100 views
2

我遇到了Laravel 5 mewebstudio/captcha问题。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(); 

     } 
    } 

我想是因为后转储会议上,我没有应放在会话验证码验证码键会不工作

(我在Captcha.php找到)
 $this->session->put('captcha', [ 
     'sensitive' => $this->sensitive, 
     'key'  => $this->hasher->make($this->sensitive ? $bag : $this->str->lower($bag)) 
    ]); 

回答

2

我解决了这个问题。

在Laravel 5.2您需要更改线路26 CaptchaServiceProvider to

$this->app['router']->get('captcha/{config?}', \Mews\Captcha\[email protected]')->middleware('web'); 
2

在Laravel 5.2,你需要在CaptchaServiceProvider改线29

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