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

hfalucas picture hfalucas  路  3Comments

harveyslash picture harveyslash  路  3Comments

marciomansur picture marciomansur  路  3Comments

functionpointdaniel picture functionpointdaniel  路  3Comments

johncloud200 picture johncloud200  路  3Comments