更新
This commit is contained in:
@@ -18,6 +18,7 @@ use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\SystemMenu;
|
||||
use app\common\model\auth\SystemRoleMenu;
|
||||
use app\common\service\qywx\QywxPromotionOperatorAccess;
|
||||
|
||||
|
||||
/**
|
||||
@@ -74,11 +75,9 @@ class AuthLogic
|
||||
->column('perms');
|
||||
|
||||
$hasAllAuth = array_diff($allAuth, $roleAuth);
|
||||
if (empty($hasAllAuth)) {
|
||||
return ['*'];
|
||||
}
|
||||
$permissions = empty($hasAllAuth) ? ['*'] : $roleAuth;
|
||||
|
||||
return $roleAuth;
|
||||
return self::appendSharedPromotionPermission($permissions, (int) ($admin['id'] ?? 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +93,28 @@ class AuthLogic
|
||||
$roleIds = AdminRole::where('admin_id', $adminId)->column('role_id');
|
||||
$menuId = SystemRoleMenu::whereIn('role_id', $roleIds)->column('menu_id');
|
||||
|
||||
return SystemMenu::distinct(true)
|
||||
$permissions = SystemMenu::distinct(true)
|
||||
->where([
|
||||
['is_disable', '=', 0],
|
||||
['perms', '<>', ''],
|
||||
['id', 'in', array_unique($menuId)],
|
||||
])
|
||||
->column('perms');
|
||||
|
||||
return self::appendSharedPromotionPermission($permissions, $adminId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static function appendSharedPromotionPermission(array $permissions, int $adminId): array
|
||||
{
|
||||
if (in_array('*', $permissions, true)
|
||||
|| in_array(QywxPromotionOperatorAccess::PAGE_PERMISSION, $permissions, true)
|
||||
|| !QywxPromotionOperatorAccess::hasSharedPagePermission($adminId)) {
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
$permissions[] = QywxPromotionOperatorAccess::PAGE_PERMISSION;
|
||||
|
||||
return array_values(array_unique($permissions));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user