2017-10-25 04:35:25 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-20 02:01:56 +00:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Remote;
|
2017-10-25 04:35:25 +00:00
|
|
|
|
2022-05-15 19:37:58 +00:00
|
|
|
use Illuminate\Validation\Rule;
|
2018-01-12 04:49:46 +00:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2017-10-25 04:35:25 +00:00
|
|
|
|
2018-01-12 04:49:46 +00:00
|
|
|
class SftpAuthenticationFormRequest extends FormRequest
|
2017-10-25 04:35:25 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Authenticate the request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rules to apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
2022-05-15 19:37:58 +00:00
|
|
|
'type' => ['nullable', 'in:password,public_key'],
|
|
|
|
'username' => ['required', 'string'],
|
|
|
|
'password' => [
|
|
|
|
Rule::when(fn () => $this->input('type') !== 'public_key', ['required', 'string'], ['nullable']),
|
|
|
|
],
|
2017-10-25 04:35:25 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return only the fields that we are interested in from the request.
|
|
|
|
* This will include empty fields as a null value.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function normalize()
|
|
|
|
{
|
|
|
|
return $this->only(
|
|
|
|
array_keys($this->rules())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|