This commit is contained in:
@ -18,7 +18,6 @@ namespace App\Middleware;
|
||||
use App\Context\UserContext;
|
||||
use App\Exception\ApiException;
|
||||
use App\JsonRpc\UserAuthServiceInterface;
|
||||
use App\Repository\Company\FirstCompanyRepository;
|
||||
use Exception;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -56,11 +55,12 @@ class CheckTokenMiddleware implements MiddlewareInterface
|
||||
|
||||
$rpcResult = $this->userAuthServiceInterface->userInfoByToken(['token' => $token]);
|
||||
|
||||
$userInfo = $rpcResult['result']['user'] ?? [];
|
||||
$userInfo = $rpcResult['result'] ?? [];
|
||||
if (!$userInfo) {
|
||||
throw new ApiException('用户信息不存在', 401);
|
||||
}
|
||||
|
||||
UserContext::setCurrentToken($token);
|
||||
UserContext::setCurrentUser($userInfo);
|
||||
|
||||
return $handler->handle($request);
|
||||
|
Reference in New Issue
Block a user