Skip to content

Commit 51defae

Browse files
committed
Merge branch 'master' into develop
2 parents 7fc4a19 + 29de208 commit 51defae

File tree

15 files changed

+140
-21
lines changed

15 files changed

+140
-21
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v0.7.16 (Derelict Dermodactylus)
7+
### Fixed
8+
* Fixed the /api/application/servers endpoint erroring when including subusers or egg
9+
* Fixed bug in migration files causing failures when using MySQL 8.
10+
* Fixed missing redirect return when an error occurs while modifying database information.
11+
* Fixes bug in login attempt tracking.
12+
* Fixes a bug where certain URL encoded files would not be editable in the file manager.
13+
14+
### Added
15+
* The application API now includes the egg's name in the egg model's response.
16+
* The /api/application/servers endpoint can now include server's databases and subusers.
17+
618
## v0.7.15 (Derelict Dermodactylus)
719
### Fixed
820
* Fixes support for PHP 7.3 when running `composer install` commands due to a dependency that needed updating.

app/Http/Controllers/Admin/DatabaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function update(DatabaseHostFormRequest $request, DatabaseHost $host): Re
165165
$this->alert->danger(
166166
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
167167
)->flash();
168-
$redirect->withInput($request->normalize());
168+
return $redirect->withInput($request->normalize());
169169
} else {
170170
throw $exception;
171171
}

app/Models/Server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ public function user()
203203
/**
204204
* Gets the subusers associated with a server.
205205
*
206-
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
206+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
207207
*/
208208
public function subusers()
209209
{
210-
return $this->hasManyThrough(User::class, Subuser::class, 'server_id', 'id', 'id', 'user_id');
210+
return $this->hasMany(Subuser::class, 'server_id', 'id');
211211
}
212212

213213
/**

app/Services/Nests/NestDeletionService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function handle(int $nest): int
5151
{
5252
$count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]);
5353
if ($count > 0) {
54-
throw new HasActiveServersException(trans('exceptions.service.delete_has_servers'));
54+
throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers'));
5555
}
5656

5757
return $this->repository->delete($nest);

app/Transformers/Api/Application/EggTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function transform(Egg $model)
4141
return [
4242
'id' => $model->id,
4343
'uuid' => $model->uuid,
44+
'name' => $model->name,
4445
'nest' => $model->nest_id,
4546
'author' => $model->author,
4647
'description' => $model->description,

app/Transformers/Api/Application/ServerTransformer.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ServerTransformer extends BaseTransformer
2828
'variables',
2929
'location',
3030
'node',
31+
'databases',
3132
];
3233

3334
/**
@@ -131,7 +132,7 @@ public function includeSubusers(Server $server)
131132

132133
$server->loadMissing('subusers');
133134

134-
return $this->collection($server->getRelation('subusers'), $this->makeTransformer(UserTransformer::class), 'user');
135+
return $this->collection($server->getRelation('subusers'), $this->makeTransformer(SubuserTransformer::class), 'subuser');
135136
}
136137

137138
/**
@@ -195,22 +196,22 @@ public function includeNest(Server $server)
195196
}
196197

197198
/**
198-
* Return a generic array with service option information for this server.
199+
* Return a generic array with egg information for this server.
199200
*
200201
* @param \Pterodactyl\Models\Server $server
201202
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
202203
*
203204
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
204205
*/
205-
public function includeOption(Server $server)
206+
public function includeEgg(Server $server)
206207
{
207208
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
208209
return $this->null();
209210
}
210211

211212
$server->loadMissing('egg');
212213

213-
return $this->item($server->getRelation('egg'), $this->makeTransformer(EggVariableTransformer::class), 'egg');
214+
return $this->item($server->getRelation('egg'), $this->makeTransformer(EggTransformer::class), 'egg');
214215
}
215216

216217
/**
@@ -269,4 +270,23 @@ public function includeNode(Server $server)
269270

270271
return $this->item($server->getRelation('node'), $this->makeTransformer(NodeTransformer::class), 'node');
271272
}
273+
274+
/**
275+
* Return a generic array with database information for this server.
276+
*
277+
* @param \Pterodactyl\Models\Server $server
278+
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
279+
*
280+
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
281+
*/
282+
public function includeDatabases(Server $server)
283+
{
284+
if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
285+
return $this->null();
286+
}
287+
288+
$server->loadMissing('databases');
289+
290+
return $this->collection($server->getRelation('databases'), $this->makeTransformer(ServerDatabaseTransformer::class), 'databases');
291+
}
272292
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace Pterodactyl\Transformers\Api\Application;
4+
5+
use Pterodactyl\Models\Subuser;
6+
use Pterodactyl\Models\Permission;
7+
use Pterodactyl\Services\Acl\Api\AdminAcl;
8+
9+
class SubuserTransformer extends BaseTransformer
10+
{
11+
/**
12+
* List of resources that can be included.
13+
*
14+
* @var array
15+
*/
16+
protected $availableIncludes = ['user', 'server'];
17+
18+
/**
19+
* Return the resource name for the JSONAPI output.
20+
*
21+
* @return string
22+
*/
23+
public function getResourceName(): string
24+
{
25+
return Subuser::RESOURCE_NAME;
26+
}
27+
28+
/**
29+
* Return a transformed Subuser model that can be consumed by external services.
30+
*
31+
* @param \Pterodactyl\Models\Subuser $subuser
32+
* @return array
33+
*/
34+
public function transform(Subuser $subuser): array
35+
{
36+
return [
37+
'id' => $subuser->id,
38+
'user_id' => $subuser->user_id,
39+
'server_id' => $subuser->server_id,
40+
'permissions' => $subuser->permissions->map(function (Permission $permission) {
41+
return $permission->permission;
42+
}),
43+
'created_at' => $this->formatTimestamp($subuser->created_at),
44+
'updated_at' => $this->formatTimestamp($subuser->updated_at),
45+
];
46+
}
47+
48+
/**
49+
* Return a generic item of user for this subuser.
50+
*
51+
* @param \Pterodactyl\Models\Subuser $subuser
52+
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
53+
*
54+
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
55+
*/
56+
public function includeUser(Subuser $subuser)
57+
{
58+
if (! $this->authorize(AdminAcl::RESOURCE_USERS)) {
59+
return $this->null();
60+
}
61+
62+
$subuser->loadMissing('user');
63+
64+
return $this->item($subuser->getRelation('user'), $this->makeTransformer(UserTransformer::class), 'user');
65+
}
66+
67+
/**
68+
* Return a generic item of server for this subuser.
69+
*
70+
* @param \Pterodactyl\Models\Subuser $subuser
71+
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
72+
*
73+
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
74+
*/
75+
public function includeServer(Subuser $subuser)
76+
{
77+
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
78+
return $this->null();
79+
}
80+
81+
$subuser->loadMissing('server');
82+
83+
return $this->item($subuser->getRelation('server'), $this->makeTransformer(ServerTransformer::class), 'server');
84+
}
85+
}

config/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
|
1313
*/
1414
'lockout' => [
15-
'time' => 120,
15+
'time' => 2,
1616
'attempts' => 3,
1717
],
1818

database/migrations/2016_10_23_193810_add_foreign_keys_servers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function up()
1616
MODIFY COLUMN owner INT(10) UNSIGNED NOT NULL,
1717
MODIFY COLUMN allocation INT(10) UNSIGNED NOT NULL,
1818
MODIFY COLUMN service INT(10) UNSIGNED NOT NULL,
19-
MODIFY COLUMN servers.option INT(10) UNSIGNED NOT NULL
19+
MODIFY COLUMN `option` INT(10) UNSIGNED NOT NULL
2020
');
2121

2222
Schema::table('servers', function (Blueprint $table) {
@@ -55,7 +55,7 @@ public function down()
5555
MODIFY COLUMN owner MEDIUMINT(8) UNSIGNED NOT NULL,
5656
MODIFY COLUMN allocation MEDIUMINT(8) UNSIGNED NOT NULL,
5757
MODIFY COLUMN service MEDIUMINT(8) UNSIGNED NOT NULL,
58-
MODIFY COLUMN servers.option MEDIUMINT(8) UNSIGNED NOT NULL
58+
MODIFY COLUMN `option` MEDIUMINT(8) UNSIGNED NOT NULL
5959
');
6060
}
6161
}

resources/views/admin/eggs/scripts.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
@extends('layouts.admin')
77

88
@section('title')
9-
Nests &rarr; Egg: {{ $egg->name }} &rarr; Scripts
9+
Nests &rarr; Egg: {{ $egg->name }} &rarr; Install Script
1010
@endsection
1111

1212
@section('content-header')
13-
<h1>{{ $egg->name }}<small>Manage install and upgrade scripts for this Egg.</small></h1>
13+
<h1>{{ $egg->name }}<small>Manage the install script for this Egg.</small></h1>
1414
<ol class="breadcrumb">
1515
<li><a href="{{ route('admin.index') }}">Admin</a></li>
16-
<li><a href="{{ route('admin.nests') }}">Service</a></li>
16+
<li><a href="{{ route('admin.nests') }}">Nests</a></li>
1717
<li><a href="{{ route('admin.nests.view', $egg->nest->id) }}">{{ $egg->nest->name }}</a></li>
18+
<li><a href="{{ route('admin.nests.egg.view', $egg->id) }}">{{ $egg->name }}</a></li>
1819
<li class="active">{{ $egg->name }}</li>
1920
</ol>
2021
@endsection
@@ -26,7 +27,7 @@
2627
<ul class="nav nav-tabs">
2728
<li><a href="{{ route('admin.nests.egg.view', $egg->id) }}">Configuration</a></li>
2829
<li><a href="{{ route('admin.nests.egg.variables', $egg->id) }}">Variables</a></li>
29-
<li class="active"><a href="{{ route('admin.nests.egg.scripts', $egg->id) }}">Scripts</a></li>
30+
<li class="active"><a href="{{ route('admin.nests.egg.scripts', $egg->id) }}">Install Script</a></li>
3031
</ul>
3132
</div>
3233
</div>

0 commit comments

Comments
 (0)