|
...
|
...
|
@@ -34,10 +34,19 @@ class LoginAuthMiddleware |
|
|
|
}
|
|
|
|
}
|
|
|
|
$groupInfo = $this->getGroup($manage);
|
|
|
|
if($groupInfo['status'] != 1){
|
|
|
|
return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户角色被禁用']);
|
|
|
|
}
|
|
|
|
//获取当前操作的路由name
|
|
|
|
$action = Route::currentRouteName();
|
|
|
|
//TODO::操作权限
|
|
|
|
$this->viewOperateAuth($groupInfo,$action);
|
|
|
|
$menuModel = new Menu();
|
|
|
|
$menu_id = $menuModel->read(['route_name'=>$action],['id']);
|
|
|
|
if($menu_id !== false){
|
|
|
|
if(strpos(','.$groupInfo['rights'].',', ','.$menu_id['id'].',') === false){
|
|
|
|
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户没有权限']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -51,30 +60,7 @@ class LoginAuthMiddleware |
|
|
|
public function getGroup($manage){
|
|
|
|
$groupModel = new Group();
|
|
|
|
$groupInfo = $groupModel->read(['id'=>$manage['gid']]);
|
|
|
|
if($groupInfo['status'] != 0){
|
|
|
|
return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户角色被禁用']);
|
|
|
|
}
|
|
|
|
return $groupInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看操作权限
|
|
|
|
* @name :viewOperateAuth
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/28 14:56
|
|
|
|
*/
|
|
|
|
public function viewOperateAuth($groupInfo,$action){
|
|
|
|
$menuModel = new Menu();
|
|
|
|
$menu_id = $menuModel->read(['route_name'=>$action],['id']);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($menu_id, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
if($menu_id !== false){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('ceshi', true) . PHP_EOL, FILE_APPEND);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($groupInfo, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($menu_id, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
if(strpos(','.$groupInfo['rights'].',', ','.$menu_id['id'].',') === false){
|
|
|
|
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户没有权限']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|