I'm using Laravel 5.2 and doing all authentication manually. So, although everything works, but I get a token mismatch error and the reason is that I'm not passing my routes through the web middleware in my routes file:
Route::group(['middleware'=>['web']],function (){
Route::get('/', function () {
return view('welcome');
})->name('home');
});
Route::social();
where Route::social(); is
public function social() {
$this->post('/signup',['uses'=>'UserController@postSignUp','as'=>'signup']);
$this->post('/signin',['uses'=>'UserController@postSignIn','as'=>'signin']);
$this->get('/dashboard',function() {
return view('dashboard');
})->middleware('auth');
}
But if I move Route::social(); to the web middleware group, it doesn't count errors and so return empty errors even if there are. How do I get around with it? I want both things!
I've the token field in my form using {!! Form::token() !!}
You are probably manually adding an
$errorarray to your view, thewebmiddleware will do the same thing so this will be overwritten. Thewebmiddleware group includes\Illuminate\View\Middleware\ShareErrorsFromSessionwhich creates an error variable in the views with validation errors.There are two ways to fix this. One is to only include the
\App\Http\Middleware\VerifyCsrfTokenmiddleware for this route. The other, wich I would prefer, is to add the route to thewebmiddleware group, but use another name for your array with errors.