vendredi 31 janvier 2020

What guard does laravel uses by default for authentication user in LoginController and RegisterController?

I have made a simple authentication with default laravel configurations. My default guard is set to web guard.

 'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

My authentication works perfectly. Now when I put this route.

 Route::group(['middleware' => ['auth']], function () {

    // Users
    Route::get('users/me', 'UserController@me')->name('users.me'); 

   //...below routes.

This route is returning the exception unauthenticated. But when I pass the guard as auth:api here in the middleware, it works. So I just want to know over which guard was my user authenticated. Since default is mentioned is web and I have not added guard() method on laravel to change the guard, why it was not taking the default web one? Is it because it is mentioned in the api routes? And if it is so, how come does it work with auth:api anyway when I have not authenticated my user over that guard.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire