2017-10-25 00:35:25 -04:00
|
|
|
<?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;
|
2017-10-25 00:35:25 -04:00
|
|
|
|
2018-01-11 22:49:46 -06:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2017-10-25 00:35:25 -04:00
|
|
|
|
2018-01-11 22:49:46 -06:00
|
|
|
class SftpAuthenticationFormRequest extends FormRequest
|
2017-10-25 00:35:25 -04:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Authenticate the request.
|
|
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function authorize(): bool
|
2017-10-25 00:35:25 -04:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rules to apply to the request.
|
2026-10-05 18:10:18 -04:00
|
|
|
*
|
|
|
|
|
* @return ValidationRules
|
2017-10-25 00:35:25 -04:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function rules(): array
|
2017-10-25 00:35:25 -04:00
|
|
|
{
|
|
|
|
|
return [
|
2022-05-15 15:37:58 -04:00
|
|
|
'type' => ['nullable', 'in:password,public_key'],
|
|
|
|
|
'username' => ['required', 'string'],
|
2022-05-15 16:00:08 -04:00
|
|
|
'password' => ['required', 'string'],
|
2017-10-25 00:35:25 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
2017-10-25 00:35:25 -04:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function normalize(): array
|
2017-10-25 00:35:25 -04:00
|
|
|
{
|
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(),
|
|
|
|
|
];
|
2017-10-25 00:35:25 -04:00
|
|
|
}
|
|
|
|
|
}
|