Simplest way for Authentication with 2 different tables laravel 5(JWT) - OneNightStudy.Com

Wednesday, 11 October 2017

Simplest way for Authentication with 2 different tables laravel 5(JWT)

Simplest way for Authentication with 2 different tables laravel 5(JWT)

I tried all the methods to make multitable auth login work but all failed like

Simplest way for Authentication with 2 different tables laravel 5(JWT)


Config::set('jwt.user', 'App\Driver');Config::set('defaults.guard','web2');Config::set('table', "drivers");Config::set('model', \App\Driver::class);Config::set('jwt.user', "App\Driver");
Config::set('guards.web2.driver','session');Config::set('guards.web2.provider','drivers');Config::set('auth.providers.drivers.driver','eloquent');Config::set('auth.providers.drivers.model',\App\Driver::class);

Finally i got the solution and it worked without changing any config file:

$userprovider = new \Illuminate\Auth\EloquentUserProvider(app('hash'), 'App\Driver');Auth::setProvider($userprovider);
$token = JWTAuth::attempt($credentials);

1 comment: