A
A
AlpineMilk2018-08-31 14:23:28
Laravel
AlpineMilk, 2018-08-31 14:23:28

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');
    }
}

My middleware
class ChatLogin
{
    
    public function handle($request, Closure $next)
    {
        if (!Auth::guard('loginChat')->check()) {
            return redirect('/chat/login');
        }
        return $next($request);
    }
}

Routes, all this is in the web file, which means middleware - the web is present there.
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');

Here are the fields in the database
5b8922ee76e2b627312512.png
Well, the auth.php file in the config
'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 .
What did I miss? I ask for help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question