tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.31k stars 1.54k forks source link

JWT multh Auth , with different models ( User Model , Customer Model ) #1889

Open murilolivorato opened 5 years ago

murilolivorato commented 5 years ago

Hello I use JWT Auth , and I am trying to make a multh auth with JWT with 2 Models . (USER Model AND CUSTOMER Model ) .

Like this -

    * USER ( for ADMINS  )
         *CUSTOMER ( for CUSTOMER )

in the User model I have this code , It works -

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable  implements JWTSubject
{
     protected $table      = 'users';
}

BUT in the modal CUSTOMER , I CAN NOT do that -


use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Customer extends Authenticatable  implements JWTSubject
{
    protected $table      = 'customer';
}

It will give Error , Do I have to USE only the USER model to authenticate ? can  I have 2 models  like that ?
lounging-lizard commented 4 years ago

This is not supported by this package, you should reconsider your database design/structure, I'd suggest looking at using roles and permissions and having a single users table.

specialtactics commented 4 years ago

Agreed, there are many ways to design this database and app wise, but you are muddying the concerns of users logging in, and types of users in your system.

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.