Fix bad API behavior
This commit is contained in:
parent
d4d9eda57a
commit
2ec76d283b
10 changed files with 86 additions and 68 deletions
|
@ -6,36 +6,16 @@ use Pterodactyl\Models\User;
|
|||
|
||||
class UpdateUserRequest extends StoreUserRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the requested user exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
$user = $this->route()->parameter('user');
|
||||
|
||||
return $user instanceof User && $user->exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the validation rules for this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
$userId = $this->route()->parameter('user')->id;
|
||||
$userId = $this->getModel(User::class)->id;
|
||||
|
||||
return collect(User::getUpdateRulesForId($userId))->only([
|
||||
'external_id',
|
||||
'email',
|
||||
'username',
|
||||
'name_first',
|
||||
'name_last',
|
||||
'password',
|
||||
'language',
|
||||
'root_admin',
|
||||
])->toArray();
|
||||
return parent::rules(User::getUpdateRulesForId($userId));
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue