mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 18:42:49 +08:00
清理技术债务,删除无用代码
This commit is contained in:
@@ -8,12 +8,5 @@ return [
|
|||||||
// 路由中间件
|
// 路由中间件
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
|
|
||||||
// // 后台视图初始化
|
|
||||||
// \app\admin\middleware\ViewInit::class,
|
|
||||||
|
|
||||||
// 检测用户是否登录
|
|
||||||
// \app\admin\middleware\CheckAdmin::class,
|
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -11,11 +11,4 @@ return [
|
|||||||
// Csrf安全校验
|
// Csrf安全校验
|
||||||
\app\admin\middleware\CsrfMiddleware::class,
|
\app\admin\middleware\CsrfMiddleware::class,
|
||||||
|
|
||||||
// 后台视图初始化
|
|
||||||
// \app\admin\middleware\ViewInit::class,
|
|
||||||
|
|
||||||
// 检测用户是否登录
|
|
||||||
// \app\admin\middleware\CheckAdmin::class,
|
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace app\admin\middleware;
|
|
||||||
|
|
||||||
use app\common\service\AuthService;
|
|
||||||
use think\Request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 废弃,新版TP不支持在中间件获取控制器相关信息
|
|
||||||
* 检测用户登录和节点权限
|
|
||||||
* Class CheckAdmin
|
|
||||||
* @package app\admin\middleware
|
|
||||||
*/
|
|
||||||
class CheckAdmin
|
|
||||||
{
|
|
||||||
|
|
||||||
use \app\common\traits\JumpTrait;
|
|
||||||
|
|
||||||
public function handle(Request $request, \Closure $next)
|
|
||||||
{
|
|
||||||
$adminConfig = config('admin');
|
|
||||||
$adminId = session('admin.id');
|
|
||||||
$expireTime = session('admin.expire_time');
|
|
||||||
/** @var AuthService $authService */
|
|
||||||
$authService = app(AuthService::class, ['adminId' => $adminId]);
|
|
||||||
$currentNode = $authService->getCurrentNode();
|
|
||||||
$currentController = parse_name($request->controller());
|
|
||||||
|
|
||||||
// 验证登录
|
|
||||||
if (!in_array($currentController, $adminConfig['no_login_controller']) &&
|
|
||||||
!in_array($currentNode, $adminConfig['no_login_node'])) {
|
|
||||||
empty($adminId) && $this->error('请先登录后台', [], __url('admin/login/index'));
|
|
||||||
|
|
||||||
// 判断是否登录过期
|
|
||||||
if ($expireTime !== true && time() > $expireTime) {
|
|
||||||
session('admin', null);
|
|
||||||
$this->error('登录已过期,请重新登录', [], __url('admin/login/index'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证权限
|
|
||||||
if (!in_array($currentController, $adminConfig['no_auth_controller']) &&
|
|
||||||
!in_array($currentNode, $adminConfig['no_auth_node'])) {
|
|
||||||
$check = $authService->checkNode($currentNode);
|
|
||||||
!$check && $this->error('无权限访问');
|
|
||||||
|
|
||||||
// 判断是否为演示环境
|
|
||||||
if(env('adminsystem.is_demo', false) && $request->isPost()){
|
|
||||||
$this->error('演示环境下不允许修改');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace app\admin\middleware;
|
|
||||||
|
|
||||||
|
|
||||||
use app\admin\service\ConfigService;
|
|
||||||
use app\common\constants\AdminConstant;
|
|
||||||
use think\App;
|
|
||||||
use think\facade\Request;
|
|
||||||
use think\facade\View;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 废弃,新版TP不支持在中间件获取控制器相关信息
|
|
||||||
* Class ViewInit
|
|
||||||
* @package app\admin\middleware
|
|
||||||
*/
|
|
||||||
class ViewInit
|
|
||||||
{
|
|
||||||
|
|
||||||
public function handle(\app\Request $request, \Closure $next)
|
|
||||||
{
|
|
||||||
list($thisModule, $thisController, $thisAction) = [app('http')->getName(), Request::controller(), $request->action()];
|
|
||||||
list($thisControllerArr, $jsPath) = [explode('.', $thisController), null];
|
|
||||||
foreach ($thisControllerArr as $vo) {
|
|
||||||
empty($jsPath) ? $jsPath = parse_name($vo) : $jsPath .= '/' . parse_name($vo);
|
|
||||||
}
|
|
||||||
$autoloadJs = file_exists(root_path('public')."static/{$thisModule}/js/{$jsPath}.js") ? true : false;
|
|
||||||
$thisControllerJsPath = "{$thisModule}/js/{$jsPath}.js";
|
|
||||||
$adminModuleName = config('app.admin_alias_name');
|
|
||||||
$isSuperAdmin = session('admin.id') == AdminConstant::SUPER_ADMIN_ID ? true : false;
|
|
||||||
$data = [
|
|
||||||
'adminModuleName' => $adminModuleName,
|
|
||||||
'thisController' => parse_name($thisController),
|
|
||||||
'thisAction' => $thisAction,
|
|
||||||
'thisRequest' => parse_name("{$thisModule}/{$thisController}/{$thisAction}"),
|
|
||||||
'thisControllerJsPath' => "{$thisControllerJsPath}",
|
|
||||||
'autoloadJs' => $autoloadJs,
|
|
||||||
'isSuperAdmin' => $isSuperAdmin,
|
|
||||||
'version' => env('app_debug') ? time() : ConfigService::getVersion(),
|
|
||||||
];
|
|
||||||
|
|
||||||
View::assign($data);
|
|
||||||
$request->adminModuleName = $adminModuleName;
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user