Answer the question
In order to leave comments, you need to log in
Why is Laravel 5.5 csrf token not generated??
Hello! For some reason, the token is not created in the database.
I am using 2 authorizations for different login pages. The first standard that I generated through artisan. And here is the second one:
In a separate folder, I created a login controller LoginController
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/chat';
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
public function showLoginForm()
{
return view('chat.chat_login');
}
public function logout(){
Auth::logout();
return redirect('/chat/login');
}
protected function guard()
{
return Auth::guard('loginChat');
}
}
class ChatLogin
{
public function handle($request, Closure $next)
{
if (!Auth::guard('loginChat')->check()) {
return redirect('/chat/login');
}
return $next($request);
}
}
Route::get('chat', 'chat\[email protected]')
->name('chat')
->middleware(\App\Http\Middleware\ChatLogin::class);
Route::get('chat/login','chat\[email protected]')
->name('chat_login');
Route::post('chat/login','chat\[email protected]')
->name('chat_login_post');
Route::get('chat/register','chat\[email protected]')
->name('chat_register');
Route::post('chat_register','chat\[email protected]')
->name('chat_register_post');
Route::get('logout','chat\[email protected]')
->name('logout');
'guards' => [
'loginChat' => [
'driver' => 'session',
'provider' => 'chats',
],
],
'providers' => [
'chats' => [
'driver' => 'eloquent',
'model' => App\Models\ChatUser::class,
],
],
{{ csrf_field() }}
And the field is present
in the template . Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question