php - Laravel 5.2 Multi-Auth with API guard uses wrong table -
i'm trying multi-auth system working users can log in via normal web portal, separate database of entities (named "robots" example) can log in via api guard token driver. no matter do, setup have not directing authentication guard correct robot database , keeps trying authenticate these requests users via tokens (which fails, because users don't have tokens).
can me find i've gone wrong?
i've started putting middleware group in kernel.php:
'api' => [ 'throttle:60,1', 'auth:api', ],
this uses settings in config/auth.php
'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'robots', ], ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => app\user::class, ], 'robots' => [ 'driver' => 'eloquent', 'model' => app\models\robot::class, ], ],
the middleware gets called in routes.php
route::group(['middleware' => 'api'], function () { route::get('api/request', 'api\requestcontroller@index'); });
it uses model:
<?php namespace app\models; use illuminate\database\eloquent\model; use illuminate\contracts\auth\authenticatable; class robots extends authenticatable { protected $fillable = [ 'serial_number','api_token', ]; protected $guard = 'robots'; protected $hidden = [ 'api_token', ]; }
any ideas?
update: on further inspection, appears of settings in auth.php not applying - there way can force these settings take effect?
actual issue/solution:
laravel has separate, mentioned cache exists exclusively config files. normal cache , class reset methods composer dump-autoload
, php artisan cache:clear
not affect cache, leading confusing state of having none of settings in auth.php file take effect.
the correct way clear cache use commands:
php artisan config:cache
php artisan config:clear
these resolved issue.
Comments
Post a Comment