Convert controller validation to Form Requests

This commit is contained in:
Shift
2024-10-31 20:46:50 +00:00
parent 812ee876e3
commit ed2b20c34f
2 changed files with 6 additions and 9 deletions
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Auth;
use App\Http\Requests\Auth\ShowLinkRequestFormForgotPasswordRequest;
use App\Http\Controllers\Controller;
use App\Jobs\SendPasswordForgottenEmail;
use App\Models\User;
@@ -37,7 +38,7 @@ class ForgotPasswordController extends Controller
/**
* @throws \Exception
*/
public function showLinkRequestForm(Request $request): void
public function showLinkRequestForm(ShowLinkRequestFormForgotPasswordRequest $request): void
{
$sent = '';
$email = $request->input('email') ?? '';
@@ -46,9 +47,6 @@ class ForgotPasswordController extends Controller
app('smarty.view')->assign('error', 'Missing parameter (email and/or apikey) to send password reset');
} else {
if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
$this->validate($request, [
'g-recaptcha-response' => 'required|captcha',
]);
}
//
// Check users exists and send an email
@@ -8,12 +8,11 @@ class ShowLinkRequestFormForgotPasswordRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
public function rules()
{
return ['g-recaptcha-response' => [
'required',
'captcha',
], ];
return ['g-recaptcha-response' => 'required|captcha'];
}
}