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
|
|
|
|
{
|
|
|
|
/**
|
2018-05-13 14:50:56 +00:00
|
|
|
* Return rules to validate mail settings POST data against.
|
2017-12-15 03:05:26 +00:00
|
|
|
*
|
|
|
|
* @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'])],
|
2020-09-26 23:29:26 +00:00
|
|
|
'mail:username' => 'nullable|string|max:191',
|
|
|
|
'mail:password' => 'nullable|string|max:191',
|
2017-12-15 03:05:26 +00:00
|
|
|
'mail:from:address' => 'required|string|email',
|
2020-09-26 23:29:26 +00:00
|
|
|
'mail:from:name' => 'nullable|string|max:191',
|
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
|
2021-01-23 20:33:34 +00:00
|
|
|
*
|
2017-12-15 03:05:26 +00:00
|
|
|
* @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));
|
|
|
|
}
|
|
|
|
}
|