Skip to content

Commit d21f70c

Browse files
committed
Merge branch 'develop' into feature/api-v1
2 parents 8a38a8a + 0ec5a4e commit d21f70c

File tree

20 files changed

+206
-232
lines changed

20 files changed

+206
-232
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
99
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value.
1010
* `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel.
1111
* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run.
12+
* `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script.
13+
* Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap.
14+
15+
### Added
16+
* Nest and Egg listings now show the associated ID in order to make API requests easier.
1217

1318
## v0.7.0-beta.3 (Derelict Dermodactylus)
1419
### Fixed

app/Http/Controllers/Server/Files/FileActionsController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ public function create(Request $request): View
9595
* @param string $file
9696
* @return \Illuminate\View\View
9797
*
98-
* @throws \Illuminate\Auth\Access\AuthorizationException
99-
* @throws \Pterodactyl\Exceptions\DisplayException
98+
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
10099
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
101100
*/
102-
public function update(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
101+
public function view(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
103102
{
104103
$server = $request->attributes->get('server');
105104

app/Http/Controllers/Server/Files/RemoteRequestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function store(Request $request): Response
101101
$this->repository->setNode($server->node_id)
102102
->setAccessServer($server->uuid)
103103
->setAccessToken($request->attributes->get('server_token'))
104-
->putContent($request->input('file'), $request->input('contents'));
104+
->putContent($request->input('file'), $request->input('contents') ?? '');
105105

106106
return response('', 204);
107107
} catch (RequestException $exception) {

app/Http/Requests/Admin/UserFormRequest.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,21 @@
77
class UserFormRequest extends AdminFormRequest
88
{
99
/**
10-
* {@inheritdoc}
10+
* Rules to apply to requests for updating or creating a user
11+
* in the Admin CP.
1112
*/
1213
public function rules()
1314
{
15+
$rules = collect(User::getCreateRules());
1416
if ($this->method() === 'PATCH') {
15-
$rules = User::getUpdateRulesForId($this->route()->parameter('user')->id);
16-
17-
return array_merge($rules, [
18-
'ignore_connection_error' => 'sometimes|nullable|boolean',
17+
$rules = collect(User::getUpdateRulesForId($this->route()->parameter('user')->id))->merge([
18+
'ignore_connection_error' => ['sometimes', 'nullable', 'boolean'],
1919
]);
2020
}
2121

22-
return User::getCreateRules();
23-
}
24-
25-
/**
26-
* @param array|null $only
27-
* @return array
28-
*/
29-
public function normalize(array $only = null)
30-
{
31-
if ($this->method === 'PATCH') {
32-
return array_merge(
33-
$this->all(['password']),
34-
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'language', 'ignore_connection_error'])
35-
);
36-
}
37-
38-
return parent::normalize();
22+
return $rules->only([
23+
'email', 'username', 'name_first', 'name_last', 'password',
24+
'language', 'ignore_connection_error', 'root_admin',
25+
])->toArray();
3926
}
4027
}

app/Http/Requests/Server/UpdateFileContentsFormRequest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use GuzzleHttp\Exception\RequestException;
1313
use Illuminate\Contracts\Config\Repository;
1414
use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException;
15+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1516
use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface;
1617
use Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException;
1718
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
@@ -80,7 +81,12 @@ private function checkFileCanBeEdited($server, $token)
8081
->setAccessToken($token)
8182
->getFileStat($this->route()->parameter('file'));
8283
} catch (RequestException $exception) {
83-
throw new DaemonConnectionException($exception);
84+
switch ($exception->getCode()) {
85+
case 404:
86+
throw new NotFoundHttpException;
87+
default:
88+
throw new DaemonConnectionException($exception);
89+
}
8490
}
8591

8692
if (! $stats->file || ! in_array($stats->mime, $config->get('pterodactyl.files.editable'))) {

app/Models/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
7676
'owner_id' => 'exists:users,id',
7777
'name' => 'regex:/^([\w .-]{1,200})$/',
7878
'node_id' => 'exists:nodes,id',
79-
'description' => 'nullable|string',
79+
'description' => 'string',
8080
'memory' => 'numeric|min:0',
8181
'swap' => 'numeric|min:-1',
8282
'io' => 'numeric|between:10,1000',

app/Models/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class User extends Model implements
115115
* @var array
116116
*/
117117
protected static $applicationRules = [
118+
'uuid' => 'required',
118119
'email' => 'required',
119120
'username' => 'required',
120121
'name_first' => 'required',
@@ -130,6 +131,7 @@ class User extends Model implements
130131
* @var array
131132
*/
132133
protected static $dataIntegrityRules = [
134+
'uuid' => 'string|size:36|unique:users,uuid',
133135
'email' => 'email|unique:users,email',
134136
'username' => 'alpha_dash|between:1,255|unique:users,username',
135137
'name_first' => 'string|between:1,255',

app/Notifications/AccountCreated.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Notifications;
114

5+
use Pterodactyl\Models\User;
126
use Illuminate\Bus\Queueable;
137
use Illuminate\Notifications\Notification;
148
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -19,7 +13,15 @@ class AccountCreated extends Notification implements ShouldQueue
1913
use Queueable;
2014

2115
/**
22-
* The password reset token to send.
16+
* The authentication token to be used for the user to set their
17+
* password for the first time.
18+
*
19+
* @var string|null
20+
*/
21+
public $token;
22+
23+
/**
24+
* The user model for the created user.
2325
*
2426
* @var object
2527
*/
@@ -28,11 +30,13 @@ class AccountCreated extends Notification implements ShouldQueue
2830
/**
2931
* Create a new notification instance.
3032
*
31-
* @param aray $user
33+
* @param \Pterodactyl\Models\User $user
34+
* @param string|null $token
3235
*/
33-
public function __construct(array $user)
36+
public function __construct(User $user, string $token = null)
3437
{
35-
$this->user = (object) $user;
38+
$this->token = $token;
39+
$this->user = $user;
3640
}
3741

3842
/**
@@ -56,12 +60,12 @@ public function toMail($notifiable)
5660
{
5761
$message = (new MailMessage)
5862
->greeting('Hello ' . $this->user->name . '!')
59-
->line('You are recieving this email because an account has been created for you on Pterodactyl Panel.')
63+
->line('You are recieving this email because an account has been created for you on ' . config('app.name') . '.')
6064
->line('Username: ' . $this->user->username)
61-
->line('Email: ' . $notifiable->email);
65+
->line('Email: ' . $this->user->email);
6266

63-
if (! is_null($this->user->token)) {
64-
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->user->token . '?email=' . $notifiable->email));
67+
if (! is_null($this->token)) {
68+
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . $this->user->email));
6569
}
6670

6771
return $message;

app/Services/Servers/BuildModificationService.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Services\Servers;
114

@@ -113,6 +106,7 @@ public function getBuild($attribute = null)
113106
*
114107
* @throws \Pterodactyl\Exceptions\DisplayException
115108
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
109+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
116110
*/
117111
public function handle($server, array $data)
118112
{
@@ -138,11 +132,11 @@ public function handle($server, array $data)
138132
}
139133

140134
$server = $this->repository->update($server->id, [
141-
'memory' => array_get($data, 'memory', $server->memory),
142-
'swap' => array_get($data, 'swap', $server->swap),
143-
'io' => array_get($data, 'io', $server->io),
144-
'cpu' => array_get($data, 'cpu', $server->cpu),
145-
'disk' => array_get($data, 'disk', $server->disk),
135+
'memory' => (int) array_get($data, 'memory', $server->memory),
136+
'swap' => (int) array_get($data, 'swap', $server->swap),
137+
'io' => (int) array_get($data, 'io', $server->io),
138+
'cpu' => (int) array_get($data, 'cpu', $server->cpu),
139+
'disk' => (int) array_get($data, 'disk', $server->disk),
146140
'allocation_id' => array_get($data, 'allocation_id', $server->allocation_id),
147141
]);
148142

app/Services/Servers/DetailsModificationService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public function edit($server, array $data)
9595

9696
$this->connection->beginTransaction();
9797
$this->repository->withoutFresh()->update($server->id, [
98-
'owner_id' => array_get($data, 'owner_id') ?? $server->owner_id,
99-
'name' => array_get($data, 'name') ?? $server->name,
100-
'description' => array_get($data, 'description') ?? $server->description,
98+
'owner_id' => array_get($data, 'owner_id'),
99+
'name' => array_get($data, 'name'),
100+
'description' => array_get($data, 'description', ''),
101101
], true, true);
102102

103103
if (array_get($data, 'owner_id') != $server->owner_id) {

0 commit comments

Comments
 (0)