Merge branch 'develop' into feature/api-v1
This commit is contained in:
commit
d21f70c04b
20 changed files with 205 additions and 231 deletions
|
@ -95,11 +95,10 @@ class FileActionsController extends Controller
|
|||
* @param string $file
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
|
||||
public function view(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
|
||||
{
|
||||
$server = $request->attributes->get('server');
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class RemoteRequestController extends Controller
|
|||
$this->repository->setNode($server->node_id)
|
||||
->setAccessServer($server->uuid)
|
||||
->setAccessToken($request->attributes->get('server_token'))
|
||||
->putContent($request->input('file'), $request->input('contents'));
|
||||
->putContent($request->input('file'), $request->input('contents') ?? '');
|
||||
|
||||
return response('', 204);
|
||||
} catch (RequestException $exception) {
|
||||
|
|
|
@ -7,34 +7,21 @@ use Pterodactyl\Models\User;
|
|||
class UserFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Rules to apply to requests for updating or creating a user
|
||||
* in the Admin CP.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = collect(User::getCreateRules());
|
||||
if ($this->method() === 'PATCH') {
|
||||
$rules = User::getUpdateRulesForId($this->route()->parameter('user')->id);
|
||||
|
||||
return array_merge($rules, [
|
||||
'ignore_connection_error' => 'sometimes|nullable|boolean',
|
||||
$rules = collect(User::getUpdateRulesForId($this->route()->parameter('user')->id))->merge([
|
||||
'ignore_connection_error' => ['sometimes', 'nullable', 'boolean'],
|
||||
]);
|
||||
}
|
||||
|
||||
return User::getCreateRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $only
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
{
|
||||
if ($this->method === 'PATCH') {
|
||||
return array_merge(
|
||||
$this->all(['password']),
|
||||
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'language', 'ignore_connection_error'])
|
||||
);
|
||||
}
|
||||
|
||||
return parent::normalize();
|
||||
return $rules->only([
|
||||
'email', 'username', 'name_first', 'name_last', 'password',
|
||||
'language', 'ignore_connection_error', 'root_admin',
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Pterodactyl\Http\Requests\Server;
|
|||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
|
@ -80,7 +81,12 @@ class UpdateFileContentsFormRequest extends ServerFormRequest
|
|||
->setAccessToken($token)
|
||||
->getFileStat($this->route()->parameter('file'));
|
||||
} catch (RequestException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
switch ($exception->getCode()) {
|
||||
case 404:
|
||||
throw new NotFoundHttpException;
|
||||
default:
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $stats->file || ! in_array($stats->mime, $config->get('pterodactyl.files.editable'))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue