Is there way to fix argument 2 passed to Tymon\\JWTAuth\\JWTGuard::__construct() using JWT and Laravel?

Viewed 531

I have problem on my jwt authentication. When I hit the api for the login of admin it shows error on my postman says that "message": "Argument 2 passed to Tymon\JWTAuth\JWTGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given.

I read some threads regarding on this, they said that there is problem on auth.php of laravel I guess it is providers.

Here is what is inside on my auth.php and my controller.

Controller

public function __construct()
{
    
    Config::set('jwt.user', Admin::class);
    Config::set('auth.providers', ['users' => [
        'driver' => 'eloquent',
        'model' => Admin::class,
    ]]);

}

Auth.php

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

    'api' => [
        'driver' => 'jwt',
        'provider' => 'assureds',
        'hash' => false,
    ],

    'admins' => [
        'driver' => 'jwt',
        'provider' => 'admins',
    ],
],

Provider:

'providers' => [
        
        'assureds' => [
            'driver' => 'eloquent',
            'model' => App\Assured::class,
        ],

        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],
0 Answers
Related