php - more than one guard in route -


i use laravel framework want use more 1 guard in route :

   route::group([ 'middleware' => 'jwt.auth', 'guard' => ['biker','customer','operator']], function () {} 

i have script in authserviceprovider.php below in boot section:

  $this->app['router']->matched(function (\illuminate\routing\events\routematched $event) {         $route = $event->route;         if (!array_has($route->getaction(), 'guard')) {             return;         }         $routeguard = array_get($route->getaction(), 'guard');         $this->app['auth']->resolveusersusing(function ($guard = null) use ($routeguard) {             return $this->app['auth']->guard($routeguard)->user();         });         $this->app['auth']->setdefaultdriver($routeguard);     }); 

that work 1 guard in route 'guard'=>'biker'
how change code in authserviceprovider.php work more 1 gaurd in route

i know old question went through issue , figured out how solve myself. might useful else. solution simple, have specify each guard after name of middleware separated commas this:

route::group(['middleware' => ['auth:biker,customer,operator'], function() {} 

the guards sent \illuminate\auth\middleware\authenticate function authenticate(array $guards) checks every guard provided in array.

this works laravel 5.4.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -