bearerToken() ?? $request->token; $token = PersonalAccessToken::findToken($token); if (!$token) { return $this->fail(StarterResponseCode::JWT_AUTH_FAIL); } $tokenable = $token->tokenable; $guards = config("auth.guards"); foreach ($guards as $k => $v) { if ($k != $guard) continue; $auth = auth()->guard($k)->loginUsingId($tokenable->id); if (!$auth) { continue; } if (get_class($auth) == get_class($tokenable)) { return $next($request); } } return $this->fail(StarterResponseCode::JWT_AUTH_FAIL); } }