Jwt-auth: Undefined index: model with multi-auth guards using version 1.0.0-beta.1

Created on 30 Mar 2017  路  3Comments  路  Source: tymondesigns/jwt-auth

Hello guys,

I have created 2 guards all using the JWT driver. One for called users and another called tutors. I am using Laravel 5.3. Authentication works perfectly with the users middleware when I declare it in my route like this and I am able to access protected routes using the token returned through authentication:

 Route::group([
            'middleware' => 'auth:api',
        ], function () {
 //user protected routes go here
});

This is how I have declared the tutor middleware route:

 Route::group([
            'middleware' => 'auth:tutor',
        ], function () {
 //tutor protected routes go here
});

When I use the tutor guard, authentication works perfectly and a token is returned to me, but anytime I try to use the token to make a request to a protected route, I get this error message:

ErrorException in CreatesUserProviders.php line 65:
Undefined index: model
in CreatesUserProviders.php line 65
at HandleExceptions->handleError('8', 'Undefined index: model', '/home/vagrant/code/studiens/vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php', '65', array('config' => array('driver' => 'eloquent', 'table' => 'App\Tutor'))) in CreatesUserProviders.php line 65
at AuthManager->createEloquentProvider(array('driver' => 'eloquent', 'table' => 'App\Tutor')) in CreatesUserProviders.php line 38
at AuthManager->createUserProvider('tutors') in AbstractServiceProvider.php line 79
at AbstractServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application), 'tutor', array('driver' => 'jwt', 'provider' => 'tutors')) in AuthManager.php line 111

What am i doing wrong?

Thanks in advance.

Most helpful comment

U should check your guard in config/auth.php check the provider which is use for the table. here example
for Model 'administrators' => [ 'driver' => 'eloquent', 'model' => App\Administrator::class, ],
for table not use a model
'administrators' => [ 'driver' => 'database', 'table' => 'administrator', ],

I hope its help

All 3 comments

U should check your guard in config/auth.php check the provider which is use for the table. here example
for Model 'administrators' => [ 'driver' => 'eloquent', 'model' => App\Administrator::class, ],
for table not use a model
'administrators' => [ 'driver' => 'database', 'table' => 'administrator', ],

I hope its help

Thank you so much @hafizu97 You saved my life 馃榾

cool, u saved my time @hafizu97

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heroghost picture heroghost  路  3Comments

lbottoni picture lbottoni  路  3Comments

harveyslash picture harveyslash  路  3Comments

marciomansur picture marciomansur  路  3Comments

NaelsonBrasil picture NaelsonBrasil  路  3Comments