Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 JWT-token with multiple tables

Tags:

jwt

laravel-5

I have a laravel 5 backend that sends an jwt-token as a json response (with https://github.com/tymondesigns/jwt-auth). The user authentication works correctly.

What i need to do is to use jwt-token for admin authentication too. Admins are on different table named admin.

How can i use jwt-token for different tables?

like image 442
user3428228 Avatar asked Mar 29 '15 20:03

user3428228


2 Answers

I had similar problem and for me was enough just create route middleware and update auth.model (needed to change only \App\User to \App\Customer):

Config::set('auth.model', App\Customer::class);

Tables and other db things you should have defined in models, so above entry should do work.

like image 54
user2987281 Avatar answered Dec 19 '22 09:12

user2987281


It worked for me , I have 2 users client and salon_owner . To change I updated 2 things auth.model and jwt.user :

Config::set('jwt.user', 'App\Salon_owner'); 
Config::set('auth.providers.users.model', \App\SalonOwner::class);
like image 41
Fares Karbia Avatar answered Dec 19 '22 09:12

Fares Karbia