| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Servers\Common;
- use App\Models\SysModels\Menu;
- /**
- * 权限验证
- */
- class PermissionServer
- {
- /**
- * 后台权限检查
- * @param $role_id
- * @param $clientRoute
- * @return bool
- */
- public static function verifyAuth($role_id, $clientRoute){
- //跳过权限认证的路由
- $url_list = [
- 'common.sts',
- ];
- if (in_array($clientRoute, $url_list) || $role_id == 0) {
- return true;
- }
- $where = [['url_name',$clientRoute], ['status',1], ['is_del',0]];
- $client_id = Menu::where($where)->value('id');
- if (empty($client_id)) {
- return false;
- }
- //获取该角色的权限节点
- $url_ids = MenuServer::creatServer()->getRole($role_id);
- if (empty($url_ids) || !in_array($client_id, $url_ids)) {
- return false;
- }
- return true;
- }
- }
|