fix: add validation to home contact form
The form wasn't previosly being validated, allowing spammers to proliferate and bypass the captcha.
This commit is contained in:
parent
d23820598f
commit
a7c76ad7b8
@ -22,6 +22,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Exceptions\FailedCaptchaException;
|
use App\Exceptions\FailedCaptchaException;
|
||||||
|
use App\Http\Requests\HomeContactRequest;
|
||||||
use App\Notifications\NewContact;
|
use App\Notifications\NewContact;
|
||||||
use App\Services\ContactService;
|
use App\Services\ContactService;
|
||||||
use App\User;
|
use App\User;
|
||||||
@ -40,7 +41,7 @@ class ContactController extends Controller
|
|||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(Request $request)
|
public function create(HomeContactRequest $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
32
app/Http/Requests/HomeContactRequest.php
Normal file
32
app/Http/Requests/HomeContactRequest.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class HomeContactRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => 'required|email',
|
||||||
|
'msg' => 'required|string',
|
||||||
|
'captcha' => 'required|string'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user