You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\middleware;
|
|
|
|
use app\auth\logic\Auth;
|
|
use app\system\logic\Login;
|
|
use app\auth\model\AuthGroupRule;
|
|
use app\auth\model\AuthRule;
|
|
use app\system\model\SystemConfig;
|
|
use app\system\model\SystemLoginer;
|
|
use think\facade\View;
|
|
|
|
class CheckAdmin
|
|
{
|
|
/**
|
|
* 处理请求
|
|
* @param \think\Request $request
|
|
* @param \Closure $next
|
|
* @date 2021-01-13
|
|
*/
|
|
public function handle($request, \Closure $next)
|
|
{
|
|
$auth_logic = new Auth();
|
|
$login_logic = new Login();
|
|
$config_model = new SystemConfig();
|
|
$system_login_er_model = new SystemLoginer();
|
|
|
|
//登录用户信息
|
|
$login_er = serializeMysql(session('login_er'),1);
|
|
//登录页面
|
|
$login_url = (string)url('User/index');
|
|
|
|
$result = $login_logic->userIsLogin();
|
|
if ($result) {
|
|
if ($request->isAjax()) {
|
|
return sendErrorArray(4004, '用户未登录',['url'=>$login_url]);
|
|
} else {
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
$controller_name = substr($request->controller(true),strripos($request->controller(true),".")+1);
|
|
$action_name = $request->action(true); //获取当前操作小写
|
|
//判断后台登录用户状态
|
|
$status = $system_login_er_model->getOneData(['id' => LID], 'status');
|
|
if ($status != 1) {
|
|
if ($request->isAjax()) {
|
|
return sendErrorArray(4005, '登录超时',['url'=>$login_url]);
|
|
} else {
|
|
return redirect($login_url);
|
|
}
|
|
}
|
|
|
|
$menu_data = $auth_logic->getMenu($controller_name,$action_name);
|
|
$config_info = $config_model->getOneData();
|
|
View::assign('config_info',$config_info);
|
|
View::assign('login_er', $login_er);
|
|
View::assign('menu', $menu_data['menu']);
|
|
View::assign('group_name', $menu_data['group_name']);
|
|
View::assign('action_name', $menu_data['auth_name']);
|
|
View::assign('three_level', $menu_data['three_level']);
|
|
View::assign('order', 1);
|
|
|
|
return $next($request);
|
|
}
|
|
|
|
}
|