mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Remote;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class SftpAuthenticationFormRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Authenticate the request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Rules to apply to the request.
|
|
*
|
|
* @return ValidationRules
|
|
*/
|
|
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.
|
|
*
|
|
* @return SftpAuthenticationData
|
|
*/
|
|
public function normalize(): array
|
|
{
|
|
return [
|
|
'type' => $this->filled('type') ? $this->string('type')->toString() : null,
|
|
'username' => $this->string('username')->toString(),
|
|
'password' => $this->string('password')->toString(),
|
|
];
|
|
}
|
|
}
|