fixed permission

修改仪表盘模块显示的权限bug
This commit is contained in:
jyiL
2020-10-28 16:49:19 +08:00
committed by GitHub
parent 14a9458c60
commit 745c51d195

View File

@@ -4,6 +4,7 @@ namespace HyperfAdmin\Admin\Controller;
use Hyperf\Utils\Str;
use HyperfAdmin\Admin\Model\FrontRoutes;
use HyperfAdmin\Admin\Service\CommonConfig;
use HyperfAdmin\Admin\Service\Menu;
use HyperfAdmin\Admin\Service\ModuleProxy;
use HyperfAdmin\BaseUtils\Constants\ErrorCode;
use HyperfAdmin\BaseUtils\Guzzle;
@@ -25,6 +26,23 @@ class SystemController extends AdminAbstractController
'open_export' => false,
'navbar_notice' => '',
]);
if (isset($config['system_module']) && !$this->auth_service->isSupperAdmin()) {
$user_id = $this->auth_service->get('id');
$role_ids = $this->permission_service->getUserRoleIds($user_id);
$router_ids = $this->permission_service->getRoleMenuIds($role_ids);
foreach ($config['system_module'] as $module_key => $module_value) {
$routers = make(Menu::class)->tree([
'module' => $module_value['name'],
'id' => $router_ids,
]);
if(empty($routers)) unset($config['system_module'][$module_key]);
}
}
return $this->success($config);
}