2016-01-13 99 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]'); 
     });