Php Laravel8:GoogleRecaptcha响应不会出现在登录表单中
我想在我的登录表单中使用Google Recaptcha系统,所以在提供了Google的Php Laravel8:GoogleRecaptcha响应不会出现在登录表单中,php,laravel,laravel-8,Php,Laravel,Laravel 8,我想在我的登录表单中使用Google Recaptcha系统,所以在提供了Google的Google Recaptcha\u SITE\u KEY&Google\u Recaptcha\u SECRET\u KEY后,我将它们添加到了我的文件中 然后我将此方法添加到LoginController.php: protected function validateLogin(Request $request) { $request->validate([ $this-&
Google Recaptcha\u SITE\u KEY
&Google\u Recaptcha\u SECRET\u KEY
后,我将它们添加到了我的文件中
然后我将此方法添加到LoginController.php
:
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
'g-recaptcha-response' => ['required', new Recaptcha]
]);
}
<div class="form-group col-md-8 offset-md-4 mb-3">
<div class="g-recaptcha" data-sitekey="{{ env('GOOGLE_RECAPTCHA_SITE_KEY') }}"></div>
@error('g-recaptcha-response')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
在包含了recaptcha脚本之后,我将其添加到了login.blade.php
:
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
'g-recaptcha-response' => ['required', new Recaptcha]
]);
}
<div class="form-group col-md-8 offset-md-4 mb-3">
<div class="g-recaptcha" data-sitekey="{{ env('GOOGLE_RECAPTCHA_SITE_KEY') }}"></div>
@error('g-recaptcha-response')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
@错误('g-recaptcha-response')
{{$message}}
@恩德罗
如您所见,当我将recaptcha字段留空时,它应该会向我显示错误消息,类似于“g-recaptcha-response字段是必需的。”但不知怎的,它不会这样做
因此,如果您知道如何解决此问题,请告诉我,谢谢。更改:
致:
将
更改为
看看它是否有效是的,没错,谢谢你,伙计。