Skip to content

Commit 813a671

Browse files
committed
Hide startup line from API response if user doesn't have startup permissions
1 parent 9ae3c17 commit 813a671

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/Services/Servers/StartupCommandService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ class StartupCommandService
1010
* Generates a startup command for a given server instance.
1111
*
1212
* @param \Pterodactyl\Models\Server $server
13+
* @param bool $hideAllValues
1314
* @return string
1415
*/
15-
public function handle(Server $server): string
16+
public function handle(Server $server, bool $hideAllValues = false): string
1617
{
1718
$find = ['{{SERVER_MEMORY}}', '{{SERVER_IP}}', '{{SERVER_PORT}}'];
1819
$replace = [$server->memory, $server->allocation->ip, $server->allocation->port];
1920

2021
foreach ($server->variables as $variable) {
2122
$find[] = '{{' . $variable->env_variable . '}}';
22-
$replace[] = $variable->user_viewable ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
23+
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
2324
}
2425

2526
return str_replace($find, $replace, $server->startup);

app/Transformers/Api/Client/ServerTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function transform(Server $server): array
6161
'io' => $server->io,
6262
'cpu' => $server->cpu,
6363
],
64-
'invocation' => $service->handle($server),
64+
'invocation' => $service->handle($server, ! $this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)),
6565
'feature_limits' => [
6666
'databases' => $server->database_limit,
6767
'allocations' => $server->allocation_limit,

0 commit comments

Comments
 (0)