Files
pterodactyl-panel/app/Http/Requests/Api/Remote/SftpAuthenticationFormRequest.php
T

48 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2018-01-19 20:01:56 -06:00
namespace Pterodactyl\Http\Requests\Api\Remote;
use Illuminate\Foundation\Http\FormRequest;
class SftpAuthenticationFormRequest extends FormRequest
{
/**
* Authenticate the request.
*/
2022-10-14 10:59:20 -06:00
public function authorize(): bool
{
return true;
}
/**
* Rules to apply to the request.
2026-10-05 18:10:18 -04:00
*
* @return ValidationRules
*/
2022-10-14 10:59:20 -06:00
public function rules(): array
{
return [
'type' => ['nullable', 'in:password,public_key'],
'username' => ['required', 'string'],
'password' => ['required', 'string'],
];
}
/**
* Return only the fields that we are interested in from the request.
* This will include empty fields as a null value.
2026-10-05 18:10:18 -04:00
*
* @return SftpAuthenticationData
*/
2022-10-14 10:59:20 -06:00
public function normalize(): array
{
2026-10-05 18:10:18 -04:00
return [
'type' => $this->filled('type') ? $this->string('type')->toString() : null,
'username' => $this->string('username')->toString(),
'password' => $this->string('password')->toString(),
];
}
}