2017-12-15 03:05:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Admin\Settings;
|
|
|
|
|
2018-02-03 18:28:39 +00:00
|
|
|
use Illuminate\Validation\Rule;
|
2017-12-15 03:05:26 +00:00
|
|
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|
|
|
|
|
|
|
class MailSettingsFormRequest extends AdminFormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return rules to validate mail settings POST data aganist.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'mail:host' => 'required|string',
|
|
|
|
'mail:port' => 'required|integer|between:1,65535',
|
2018-02-03 18:28:39 +00:00
|
|
|
'mail:encryption' => ['present', Rule::in([null, 'tls', 'ssl'])],
|
|
|
|
'mail:username' => 'nullable|string|max:255',
|
|
|
|
'mail:password' => 'nullable|string|max:255',
|
2017-12-15 03:05:26 +00:00
|
|
|
'mail:from:address' => 'required|string|email',
|
2018-02-03 18:28:39 +00:00
|
|
|
'mail:from:name' => 'nullable|string|max:255',
|
2017-12-15 03:05:26 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override the default normalization function for this type of request
|
|
|
|
* as we need to accept empty values on the keys.
|
|
|
|
*
|
|
|
|
* @param array $only
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-02-03 18:28:39 +00:00
|
|
|
public function normalize(array $only = null)
|
2017-12-15 03:05:26 +00:00
|
|
|
{
|
|
|
|
$keys = array_flip(array_keys($this->rules()));
|
|
|
|
|
|
|
|
if (empty($this->input('mail:password'))) {
|
|
|
|
unset($keys['mail:password']);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->only(array_flip($keys));
|
|
|
|
}
|
|
|
|
}
|