mirror of
http://124.126.16.154:8888/singularity/hyperf-admin.git
synced 2026-01-15 06:55:06 +08:00
fix: PermissionService 路由解析
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user