这个错误让我发疯。我正在尝试创建一个检索密码表单,当我提交它时,这个错误一直被抛出。令牌肯定是提供的,所以我不知道出了什么问题。到目前为止,这只发生在我的本地。它不会发生在生产中。同时,不确定它是否相关,我明白了
InvalidStateException in AbstractProvider.php line 191
当我尝试使用社交名流(google & fb)登录时。一个往往会在另一个发生时发生。如果我从提交表单中得到 tokenMismatch 然后尝试登录,我会收到此错误。
无论如何,这是表格。我真的需要帮助
{!! Form::open(['method'=>'post', 'action'=>'PasswordRetrieveController@getUser','id'=>'retrieve-pw-form'])!!}
<div class='form-group'>
{!! form::label('email','Email Address')!!}
{!!Form::text('email','',['class'=>'form-control','type'=>'email','required'=>'required'])!!}
</div>
{!!Form::submit('submit',['class'=>'btn btn-md btn-default'])!!}
{!!Form::close()!!}
这是控制器。它永远不会碰到我的 getUser 函数。只是抛出 tokenMismatch 错误。
<?php
namespace App\Http\Controllers;
use App\User;
use App\SecurityQuestions;
use Mail;
use Redirect;
use Illuminate\Http\Response;
use Illuminate\Http\Request;
class PasswordRetrieveController extends Controller{
public function index(){
return view('password.index');
}
public function getUser(Request $request){
$email = $request->get('email');
$user = User::where('email',$email)->first();
if ($user == null){
return Redirect::back()->with('message','This email does not exist');
}
if(($user->password == null) && (!empty($user->provider))){
return Redirect::back()->with('message','A password for this email does not exist. Log back in with facebook or google');
}
else{
$tmp_pw = $this->generate_tmp_pw($user);
return Redirect('password.security_question_1');
}
}
public function security_questions(){
echo 1 ;exit;
}
private function generate_tmp_pw($user){
$tmp_pw= str_random(10);
$user->tmp_password = $tmp_pw;
$user->save();
return $tmp_pw;
}
}