Lravel 5.4: JWT API with multi-auth on two tables one works the other not

后端 未结 3 586
闹比i
闹比i 2020-12-16 08:31

I am using...

  • Laravel 5.4
  • tymon/jwt-auth : 1.0.0-rc.2

I have application with two authentications API one is customers and

3条回答
  •  执念已碎
    2020-12-16 08:43

    There is no need to change the providers in config/auth.php.

    You can change the __construct function in each of your controllers as follows. So that jwt know which model to authenticate.

    DriverController

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

提交回复
热议问题