优化游戏用户信息展示-只显示当前渠道
This commit is contained in:
@@ -19,6 +19,16 @@ class User extends Backend
|
|||||||
*/
|
*/
|
||||||
protected ?object $model = null;
|
protected ?object $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据范围:非超管仅本人 + 下级角色组内管理员(与 auth.Admin 一致,见 Backend::getDataLimitAdminIds parent)
|
||||||
|
*/
|
||||||
|
protected bool|string|int $dataLimit = 'parent';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* admin_id 由表单选择归属管理员,勿在保存时强制改为当前登录账号
|
||||||
|
*/
|
||||||
|
protected bool $dataLimitFieldAutoFill = false;
|
||||||
|
|
||||||
protected array|string $preExcludeFields = ['id', 'uuid', 'create_time', 'update_time'];
|
protected array|string $preExcludeFields = ['id', 'uuid', 'create_time', 'update_time'];
|
||||||
|
|
||||||
protected array $withJoinTable = ['gameChannel', 'admin'];
|
protected array $withJoinTable = ['gameChannel', 'admin'];
|
||||||
@@ -59,8 +69,15 @@ class User extends Backend
|
|||||||
}
|
}
|
||||||
$data['uuid'] = md5(trim($username) . '|' . $channelId);
|
$data['uuid'] = md5(trim($username) . '|' . $channelId);
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
$data[$this->dataLimitField] = $this->auth->id;
|
$allowed = $this->getDataLimitAdminIds();
|
||||||
|
$adminIdNew = $data['admin_id'] ?? null;
|
||||||
|
if ($adminIdNew === null || $adminIdNew === '') {
|
||||||
|
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
||||||
|
}
|
||||||
|
if ($allowed !== [] && !in_array($adminIdNew, $allowed)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
@@ -141,6 +158,14 @@ class User extends Backend
|
|||||||
$data['uuid'] = md5(trim($nextUsername) . '|' . $nextChannelId);
|
$data['uuid'] = md5(trim($nextUsername) . '|' . $nextChannelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
$allowed = $this->getDataLimitAdminIds();
|
||||||
|
$adminIdAfter = array_key_exists('admin_id', $data) ? $data['admin_id'] : ($row['admin_id'] ?? null);
|
||||||
|
if ($allowed !== [] && $adminIdAfter !== null && $adminIdAfter !== '' && !in_array($adminIdAfter, $allowed)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
$this->model->startTrans();
|
$this->model->startTrans();
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user