adds better error messaging

This commit is contained in:
Godfrey M 2023-09-28 11:29:46 -07:00
parent b7901ae2d8
commit c21586dee5
5 changed files with 1850 additions and 1635 deletions

View file

@ -26,10 +26,13 @@ class SlackSettingsForm extends Component
protected $rules = [
'webhook_endpoint' => 'url|required_with:webhook_channel|starts_with:http://,https://,ftp://,irc://,https://hooks.slack.com/services/|nullable',
'webhook_endpoint' => 'required_with:webhook_channel|starts_with:http://,https://,ftp://,irc://,https://hooks.slack.com/services/|url|nullable',
'webhook_channel' => 'required_with:webhook_endpoint|starts_with:#|nullable',
'webhook_botname' => 'string|nullable',
];
public $messages = [
'webhook_endpoint.starts_with' => 'your webhook endpoint should begin with http://, https:// or other protocol.',
];
public function mount() {
$this->webhook_text= [
@ -120,8 +123,8 @@ class SlackSettingsForm extends Component
try {
$test = $webhook->post($this->webhook_endpoint, ['body' => $payload]);
if($test->getStatusCode() == 302){
return session()->flash('error' , 'This endpoint returns a redirect. For security reasons, we dont follow redirects. Please use the actual endpoint');
if(($test->getStatusCode() == 302)||($test->getStatusCode() == 301)){
return session()->flash('error' , 'ERROR: 301/302 '.$this->webhook_endpoint.' returns a redirect. For security reasons, we dont follow redirects. Please use the actual endpoint.');
}
$this->isDisabled='';
$this->save_button = trans('general.save');

3468
composer.lock generated

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"/livewire.js":"/livewire.js?id=c69d0f2801c01fcf8166"}
{"/livewire.js":"/livewire.js?id=90730a3b0e7144480175"}