fix: PermissionService 路由解析

This commit is contained in:
刀刀
2020-06-28 18:40:29 +08:00
parent e3066b0910
commit 7710942b6a
2 changed files with 10 additions and 10 deletions

View File

@@ -5,21 +5,16 @@
*/
namespace HyperfAdmin\Admin\Middleware;
use FastRoute\Dispatcher;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface as HttpResponse;
use Hyperf\HttpServer\CoreMiddleware;
use Hyperf\HttpServer\Router\Dispatched;
use Hyperf\Logger\LoggerFactory;
use HyperfAdmin\Admin\Service\AuthService;
use HyperfAdmin\Admin\Service\CommonConfig;
use HyperfAdmin\Admin\Service\ModuleProxy;
use HyperfAdmin\Admin\Service\PermissionService;
use HyperfAdmin\BaseUtils\AKSK;
use HyperfAdmin\BaseUtils\Constants\ErrorCode;
use HyperfAdmin\BaseUtils\Guzzle;
use HyperfAdmin\BaseUtils\Log;
use HyperfAdmin\BaseUtils\Redis\Redis;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
@@ -72,11 +67,16 @@ class PermissionMiddleware extends CoreMiddleware
$module_proxy = make(ModuleProxy::class);
if ($module_proxy->needProxy()) {
$res = $module_proxy->request();
if(isset($res['payload']) && $res['payload'] === []) {
if (isset($res['payload']) && $res['payload'] === []) {
$res['payload'] = (object)[];
}
$response = $this->response->json($res);
Log::get('http')->info('proxy_end', ['module' => $module_proxy->getTargetModule(), 'path' => $path, 'response' => $response]);
Log::get('http')->info('proxy_end', [
'module' => $module_proxy->getTargetModule(),
'path' => $path,
'response' => $response,
]);
return $response;
}
@@ -116,7 +116,7 @@ class PermissionMiddleware extends CoreMiddleware
}
/**
* @param int $code
* @param int $code
* @param string|null $message
*
* @return \Psr\Http\Message\ResponseInterface

View File

@@ -327,9 +327,9 @@ class PermissionService
if ($routes[1]->callback instanceof \Closure) {
return true;
}
[$controller, $action] = [$routes[1]->callback[0], $routes[1]->callback[1]];
[$controller, $action] = $this->prepareHandler($routes[1]->callback);
} else {
[$controller, $action] = $this->prepareHandler($routes[1]);
return false;
}
$controllerInstance = container($controller);
if (in_array($action, $controllerInstance->open_resources)) {