Open xxRockOnxx opened 7 years ago
if you use laravel 5.5, i and 1.0-rc1 i actually did it by renaming my middleware alias in something else than jwt.auth because it's used by laravel service provider to set the basemiddleware instead.
then in your own middleware you can decode the token and use the guard you want :
$type = JWTAuth::parseToken()->getPayload()->get('type');
$id = JWTAuth::parseToken()->getPayload()->get('sub');
if (! $user = Auth::guard(lcfirst($type))->loginUsingId($id)) {
return response()->json(['user_not_found'], 404);
}
Auth::setUser($user);
I need a way to specify a guard to be used aside from setting a default guard. Haven't find anything helpful yet.