Check owner before operating player

This commit is contained in:
Pig Fang 2019-04-23 13:09:06 +08:00
parent b70004ec0f
commit d8f08176a2

View File

@ -483,11 +483,13 @@ class AdminController extends Controller
return json(trans('general.unexistent-player'), 1);
}
if ($player->user()->first()->uid !== $currentUser->uid) {
if ($player->user->permission >= $currentUser->permission) {
$owner = $player->user;
if (
$owner && $owner->uid !== $currentUser->uid &&
$owner->permission >= $currentUser->permission
) {
return json(trans('admin.players.no-permission'), 1);
}
}
if ($action == 'texture') {
$this->validate($request, [
@ -531,8 +533,7 @@ class AdminController extends Controller
$player->name = $name;
$player->save();
if (option('single_player', false)) {
$owner = $player->user;
if (option('single_player', false) && $owner) {
$owner->nickname = $name;
$owner->save();
}