Jwt-auth: Basic laravel 5.5 auth not working anymore after the jwt configuration

Created on 22 Dec 2017  路  2Comments  路  Source: tymondesigns/jwt-auth

How to make basic laravel 5.5 auth work along JWT authentication?

Most helpful comment

1- auth config

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

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'jwt',
            'provider' => 'users',
        ],
    ],

2- You need to tell basic auth to use web guard instead of api. You can achieve that by overriding guard() method inside auth controllers like LoginController and others. See Authentication Quickstart > Guard Customization

protected function guard()
{
    return Auth::guard('web');
}

3-Last but not least, you need to make all controllers and routes guarded by auth to explicitly use web guard as they will use api by default because you have specified it as default guard.
Here is an example of HomeController

class HomeController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth:web');
    }
}

Thats all :)

All 2 comments

Did you find a fix to this?

1- auth config

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

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'jwt',
            'provider' => 'users',
        ],
    ],

2- You need to tell basic auth to use web guard instead of api. You can achieve that by overriding guard() method inside auth controllers like LoginController and others. See Authentication Quickstart > Guard Customization

protected function guard()
{
    return Auth::guard('web');
}

3-Last but not least, you need to make all controllers and routes guarded by auth to explicitly use web guard as they will use api by default because you have specified it as default guard.
Here is an example of HomeController

class HomeController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth:web');
    }
}

Thats all :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennethtomagan picture kennethtomagan  路  25Comments

sanjukaniyamattam picture sanjukaniyamattam  路  23Comments

rajabishek picture rajabishek  路  49Comments

mcblum picture mcblum  路  48Comments

Milos0110 picture Milos0110  路  49Comments